Linq-language integrated query of C# programming

1. What is Linq

Linq is a query technology provided by Microsoft that can be directly introduced into programming languages

  • Linq's query operations can be communicated through the programming language itself, instead of embedding strings into the application code.

2. The role of Linq

  • Write less code to create a complete application

3. The basic composition of Linq

  • Linq to SQL component, can query data based on relational database (including addition, deletion, modification, query, sorting, collection, partition)
  • Linq to DataSet component, can query DataSetobject data
  • Linq to Object components can be queried Ienumerableor Ienumerable<T>collected
  • Linq to XML component, can query or manipulate XMLstructured data, and a brand-new programming interface for processing XML documents

4. Namespace

system.Linq; Named controls: Provides classes and interfaces to host queries using Linq
system.Data.Linq; Namespace: Provides Linq to sql related classes, structures, interfaces, and enumeration
system.XML.Linq; Namespace: Provides and Linq to XML related classes and interfaces

5. 8 basic clauses:

Keyword Description
from Specify range variables and data sources
where Filter data from the data source
select Specify the type or manifestation of the element in the query result
group Group query results
orderby Sort query elements (ascending / descending)
into Provide an identifier that can be used as a reference to the results of join, group, and select clauses
join Connect two data sources
let Generate a range variable used to store the query result of the sub-expression in the query expression

6. Linq syntax format:

var 临时数据 = from 临时变量 int 集合对象(或数据库对象) 
				where 条件orderby 排序(默认为升序)select 临时变量;

Guess you like

Origin blog.csdn.net/qq_43562262/article/details/106800114