Language Integrated Query ( LINQ , pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages using a syntax reminiscent of SQL. Many of the concepts that LINQ has introduced were originally tested in Microsoft's Cω research project. LINQ was released as a part of .NET Framework 3.5 on November 19, 2007. LINQ is available for any .NET languages. Through visual Studio you can find support for C#, VB.NET. LINQ is a uniform programming model for any kind of data it introduces queries as first class concept in any .NET languages.
You can write LINQ queries against various enumerable data sources (that is, a data source that implements the IEnumerable interface). Examples are in-memory data structures (Collections, Lists, etc.,), XML documents, SQL databases, and DataSet objects. LINQ to SQ L: Allows to querying a relational structure by converting LINQ query into a native SQL Query. LINQ to Dataset : Interacts with data already in ADO.NET DataSet structures. LINQ to Entity : To query a logical model that usually has a higher-level representation of data information compared to direct access to relational data sources. When LINQ query operates on data that is on relational database, the LINQ query generates an equivalent SQL statements.
The above query can be applied to SQL Database , DataSet, or an array of objects in memory or many other kinds of data. Here Customer could be a collection of objects. The SQL like syntax in LINQ called as query expressions . The reason to start with a from clause instead of a select statement, as in SQL syntax, is related to the need to provide Microsoft IntelliSense capabilities within the remaining part of the query, which makes writing conditions, selections, and any other LINQ query clauses easier.
At the core, LINQ works over anything that implements IEnumerable . Natively includes a number of lists that are part of the .NET Framework as well as lists you create. It also works with lists of elements and attributes present in XML documents as well as fields and tables present in DataSets. By extending the base IEnumerable with a new interface, IQueryable , we can add a layer which retains the query structure and has the ability to translate it into a language more native to the underlying data source (like TSQL for SQL Server). Out of the box, the .NET Framework ships with two such providers: LINQ to SQL and LINQ to Entities.
The where query operator defines the restriction to filter the collection. The Orderxx operators are used for sorting. ThenBy and ThenByDescending operators are used for a secondary sort if the first sort gives similar result.
The where query operator defines the restriction to filter the collection. The Orderxx operators are used for sorting. ThereBy and ThereByDescending operators are used for a secondary sort if the first sort gives similar result.