Header Ads

What is LINQ ? - (Language-Integrated Query)



LINQ is a Language Integrated Query it enables, we can access all datasource with C# expression.

Language Integrated Query (LINQ), is a component released within the .NET 3.5 Framework. It is one of the most powerful features of .NET 3.5. It serves the purpose of querying objects.

LINQ comprises a series of operators, which are used to query, filter and project data in arrays, enumerable classes, relational databases and XML. In order to query data, the data needs to be encapsulated as an object. In case the data source is not an object, it first needs to be converted to an object in order for LINQ to query it.

LINQ has its own Query Processing Engine. The information returned by a LINQ query is a collection of in-memory object which may be enumerated.

The LINQ concept treats the data source as an Object, rather than a Database. So we may say, its an object that is queried. LINQ may query any type of data source, like:

LINQ to SQL (MS SQL Server supported).
LINQ to Datasets (Querying is possible on Datasets and DataTables)
LINQ to ORM Solution
LINQ to Objects (In-memory data may be queried)
LINQ to XML (Querying is possible on XML data source
LINQ supports querying to those objects that implement the IEnumerable Interface.

In the example code below, LINQ is being used to query a simple array containing integers:

int[] values = new int[] {4,5,6,7};
var output = from i in values where i < 4 orderby i select i; foreach(int j in values) Response.Write(j);


Note: For writing code in C# that understands the LINQ syntax, the System.Linq namespace needs to be used.



For More : http://msdn.microsoft.com/en-in/library/bb308959(en-us).aspx

No comments:



Powered by Blogger.