TAILIEUCHUNG - Hướng dẫn học Microsoft SQL Server 2008 part 83

Trong một truy vấn LINQ, các khoản đầu tiên là các khoản từ, xác định nguồn gốc của dữ liệu, và nó phải kết thúc với một điều khoản hoặc SELECT, khoản một GROUP. Các khoản đầu tiên, được gọi là một máy phát điện, xác định nơi dữ liệu sẽ được phát ra từ khi truy vấn được thực hiện. | PartV Data Connectivity 4 WHERE 5 GROUP BY 6 WITH 7 HAVING 10 ORDER BY Notice that the FROM clause is processed first while the SELECT clause is processed almost last. Any clause that is not specified in the query is simply skipped by the query processing engine. This information is important because it points out the similarities between LINQ query syntax and how SQL Server processes a query. r- r - For more information on SQL logical query flow please see Chapter 8 Introducing Basic Query Flow. In a LINQ query the first clause is the FROM clause which specifies the source of the data and it must end with either a SELECT clause or a GROUP clause. The first clause called a generator defines where the data will be coming from when the query is executed. It also specifies the range variable that is used as a reference for each element in the data source. For example the following uses LINQ to return a list of the directories in the root of a hard drive Directoryinfo di new DirectoryINfo C var query from dir in order by select new foreach var item in query In this example the first statement creates a new instance of the Directoryinfo class. This is what is used to retrieve a list of the directories. The second statement is the LINQ statement. The variable var is the query variable. This variable does not store actual result data. The results are produced during the iteration of the query which is done in the foreach loop. When the foreach statement executes the query results are returned during each iteration in the variable item. Whereas the LINQ query and the T-SQL query are executed similarly the T-SQL query syntax is a bit different. In T-SQL the query would be executed internally following the steps described earlier. With LINQ the query does not need to go through the rewriting process. In the next example the LINQ query uses the same syntax to query data from the Contact table in the AdventureWorks

TÀI LIỆU MỚI ĐĂNG
15    37    0    17-09-2021