Friday, August 20, 2010

Introduction to LINQ (Language Integrated Query) in C#

Introduction to LINQ (Language Integrated Query)

 Language Integrated Query (LINQ) is Microsoft's new technology for powerful, general purpose data access

 LINQ is a uniform programming model for any kind of data. LINQ enables you to query and manipulate data with a consistent model that is independent from data sources.

 LINQ is just another tool for embedding SQL queries into code

 This toolset can be used to access data coming from in-memory objects (LINQ to Objects), Databases (LINQ to SQL), XML documents (LINQ to XML), a file-system, or any other source.

 Query expressions start with the keyword from, and are written using SQL-like query operators such as Select, Where, and OrderBy:

 Every query starts with a from clause and ends with either a select clause or a group clause. 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. A select clause projects the result of an expression into an enumerable object. A group clause projects the result of an expression into a set of groups, based on a grouping condition, where each group is a numerable object.

 LINQ works on collections that implement IEnumerable.

No comments: