Click here to Skip to main content
15,896,539 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
What is LINQ? Explain with some codes how LINQ is used to fetch data from Sql database?
Posted
Updated 24-Jun-10 23:49pm
v2
Comments
Smithers-Jones 25-Jun-10 6:56am    
Looks like a homework-question or from an exam.

Counter-question: What is Google? Explain with some example-queries, how Google shows its search-results.
Or is this some kinda trick question?
William Winner 25-Jun-10 14:04pm    
Reason for my vote of 1
learn to use google. It will save you time.
bbirajdar 13-Aug-12 6:30am    
and ours too..!!!

LINQ is a language construct that allows one to use an SQL-like syntax to sort, filter and otherwise rearrange a group of objects of a similar type.

From the Microsoft documentation:
LINQ makes a query a first-class language construct in C# and Visual Basic. You write queries against strongly typed collections of objects by using language keywords and familiar operators. The following illustration shows a partially-completed LINQ query against a SQL Server database in C# with full type checking and IntelliSense support.

The title "Link To X" refers to the ability to use LINQ to query a data source of type X, e.g. LINQ to SQL, LINQ to XML, etc.

WRT fetching data from a SQL database, you will first need a DataContext. This establishes the source for your data. Then you need some classes that are representative of your tables. Then you can do this:

IQueryable<customer> custQuery =
from cust in Customers
where cust.City == "London"
select cust;

Start here: http://msdn.microsoft.com/en-us/library/bb386940.aspx[^]
 
Share this answer
 
v2
here i am posting some thing about Linq basic operation select, insert, delete, update.

http://suhasharidas.blogspot.in/2012/08/create-linq-to-sql-connection-with.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900