Linq query nested subqueries

Development tools and key technologies: Visual Studio
Author: Xiaoguang Bin
wrote Time: April 14, 2019
in the MVC query, we learn the basic simple Linq single-table queries and Linq multi-table query, there are many of our query writing, to explain the following nested sub-queries in Linq query written, did not talk much, first on the map
Here Insert Picture Description
where we create an entity class, entity class believe we all know is doing with that we can put good package data to be used, inside, let {get; set}, we will both write data, which also reads data from the outside, is a take switch data, as in the above entity class inside it, had already written a list, but we are in a field in the list is nested inside a list. Nested list through the list, you should know the following wording Linq query I have to say in a nested subquery how to write
Here Insert Picture Description
in this process the query, the query can we know the two different tables, nested inside the select query is the wording of the sub-queries, we can theoretically unlimited nested, as long as our logic processing over more nested no problem, but it is not necessary, usually we only need two or three on enough. Here it is the first implementation of the outer query, the query external finish writing and then perform sub-queries, check out the condition of the outside as a result of sub-queries, where in the two tables by the conditions inside and outside together, two tables must be associated, which is a foreign key to the outside of a master key, if two tables had nothing to do, then there will be a query error, even if there is no error in it, when we run a server error is not check out, so the two tables must be associated, this is some of the details we write code, because often we are wrong details, but we are hard to find, so pay attention!
Here Insert Picture Description
Finally, we return to encapsulate them into json data to a page on the line, this is the nested query in Linq subquery.
! ! ! Personal notes from the above sort of teacher in the class, if wrong, please correct me.

Guess you like

Origin blog.csdn.net/qq_44505797/article/details/89292809