What is LINQ

Posted by Sksingh under LINQ category on | Points: 40 | Views : 2895
(LINQ)language-integrated query to indicate that query is an integrated feature of the developer's primary programming languages (for example, Visual C#, Visual Basic). Language-integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code.

LINQ is similar to SQL query that is consist of three parts .
1. Source
2. Expression
3. Selection

var elements = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
var results = from e in elements // Source
where e > 3 // Expression
select e; // Selection

Above example is to get all the array values which are greater than 3.

Note : All LINQ expressions always return a collection, even if the data is single

Comments or Responses

Posted by: Ndebata on: 6/8/2011 Level:Starter | Status: [Member] | Points: 10
Hi Sunil,
Not All, Some are like First() ,FirstOrDefault(), Count() etc will not return a collection.


Login to post response