1. The LINQ query operation contains the following three different and independent actions:
Get Data Source
Create Query
Execute Query
2. There are two types of execution of the LINQ query:
※Delayed execution
When creating a query, the query variable itself does not execute the query, does not contain any data, and does not take any other action. It is only a query placeholder and an ienumerable object. The query is executed only when the elements of this object are enumerated.
※Execute now
Any LINQ query that returns a single value will be executed immediately, such as Count and Max. You can also call the tolist and toarray methods to force the query to be executed immediately. This method is useful when you want to cache the query results.
3, T-SQL query according to the following order in a certain logic processing query:
(8) Select
(9) Top
(1) From
(3) join
(2) On
(4) Where
(5) group
(6)
(7) having
(10) order
The execution of a LINQ query is similar to that of a T-SQL query.
4. Use VaR as little as possible when the type is known. Excessive use of VaR will reduce the readability of source code for subsequent developers.
5. The LINQ provider is a library that can implement the functions provided by the standard query operator for a specific type of data source, it is responsible for executing a given query or handing it over to another engine for execution. LINQ has multiple providers: LINQ to XML, LINQ to datasets, LINQ to objects, and LINQ to SQL.
6. Int [] number1 = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
Int [] number2 = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
VaR F1 = number1.sequenceequal (number2 );
VaR F2 = number1.equals (number2 );
F1 returns true, F2 returns false, because sequenceequal enumerates two data sources in parallel and compares whether the corresponding elements are the same, while equal compares whether the same object is referenced.
LINQ study Note 1