LINQ- Language-Integrated Query-
LINQ provides a common syntax for querying any type of data source. LINQ is collection of extensions to the .Net Framework 3.0 and its managed languages that set the query as an object. It defines a common syntax and a programming model to complex query operations against any enumerable object.
Query expressions use a whole new set of keywords Sorting, Skip, SkipWhile ,Take, TakeWhile and the relational operators like Join, Group, Select, Project, , Partition, Set operations etc., are implemented in LINQ and the C# compilers in the .Net framework 3.0, which support the LINQ syntax and makes it possible to work with a configured data store without using data sources query.
There are following assemblies used,
- using System.Linq -This is main assembly for Linq query on collections
- using System.Collections.Generic- this is used for linq to object
- using System.Data.Linq- This is for Linq to Sql
- using Sytem.Xml.Linq.Mapping – this is Designates a class as an entity associated with a database.
Query expression is used two types-
LINQ Operators
LINQ defines a set of standard query operators that allow traversal, filter, and projection operations to be expressed directly in any .NET-based language.
Basic Operators is used “From ,Where, in,select”.
Ex.
- int[] array = { 1, 2, 3, 6, 7, 8 };
- // Query expression.
- var elements = from element in array
- orderby element descending
- where element > 2
- select element;
- // Enumerate
- Response.Write(string.Format("-------------"));
- foreach (var element in elements)
- {
- Response.Write(string.Format("{0} </br>", element));
- }



Join the conversation! Your thoughts help the community grow.