check sentence

Eight query clauses:

from、where、select、group、orderby、into、join、let子句

Clause Description:

(1) LINQ query expressions must start with a from clause and must end with a select or group clause.

(2) Between the first from clause and the last select or group clause, the query expression can contain one or more where, orderby, group, join, let clauses, and even from clauses.

(3) In addition, the join and group clauses can also use the into clause to specify a temporary identifier.

Form clause:

Specify the data source and scope variables for query operations

Note: The type of the data source specified by the form clause must be IEnumerable, IEnumerable<T>, or a derived type of the first two


Select clause:

Specify the type and representation of query results


Where clause:

Logical conditions for filtering elements, generally composed of logical operators


Group clause:

Group queries

Note: TKey specifies the type of the key of IGrouping<TKey, TElement>, and TElement specifies the type of the value of IGrouping<TKey, TElement>. Accessing values ​​of type IGrouping<TKey,TElement> is very similar to accessing elements of IEnumerable<T>


Orderby clause:

Sort the query results, which can be "ascending" or "descending"

Note: The default sorting method for query results by LINQ query expressions is "ascending"


Into clause:

Connect data sources for multiple query operations


Join clause:

Introduce scope variables for storing the results of subexpressions in query expressions

The join clause can implement the following three join relationships:

(1) Inner join, the join relationship of elements must satisfy the two data sources being joined at the same time

(2) Group joins, join clauses with into clauses

(3) Left outer join


Let clause:

Provides a temporary identifier that acts as the result of a join, group or select clause


Screenshot of simple query code:


Screenshot of complex query code:


Aggregate query code screenshot:


Screenshot of group query code:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325505604&siteId=291194637