IQueryable Temp=(from c in dbContext Custorm Where Arthur c. usName. The Contains (" useful ") & amp; & C.I d==2 Select c); Interface is generally not is done with object assignment, IQueryable
The assignment of the right of the whole is an object? To understand the next IQueryable To achieve a, if the right is a IQueryable The object of the interface, it is how to keep to the right of Expression on the internal variable Expression, this is how to do it, do you have any source On the right side is a what kind? Expression or objects, object types is what language is the object? CodePudding user response:
First you don't care what he is saved to the internal variable Expression, how to do it, is there a source of problems, Just according to the condition query out the SQL on the right, then assigned to the IQueryable You don't have (from c... ). toList () before, he only generates a SQL statement, No actual data query, The benefits of doing this is lazy loading, CodePudding user response:
Moderator say I understand, also saw many IQueryable introduction, but then the question is asked, want to know the specific process, not only do what is good CodePudding user response:
refer to the second floor have water, cold response: moderator said I understand, also saw the introduction of many IQueryable, but then the question is asked, want to know the specific process, not only do this have what good The compiler will analyze your (from c... ) and the corresponding element, deposit to the Expression tree, With this Expression, can be converted into SQL statements, This is the source code: https://referencesource.microsoft.com/#System.Core/System/Linq/IQueryable.cs, 393160475 d9b88ef CodePudding user response:
thank you CodePudding user response:
On the right side is a what kind? Expression or objects, object types is what language is the object? == On the right is the Expression, also is the object, it is Expression type of object, You remember c # is an object-oriented language, everything, so, such as trust is also a class, as it is difficult to understand? In object-oriented languages, you are the object should be used to solve the problem, CodePudding user response:
Eldest brother said, and I saw an article introduces iqueryable today is very much like, he said some more detailed "The essence of the lambda expressions is an anonymous methods, Func To entrust, is a generic type is objectified method, had entrusted we can operate it as an object as a method, operation such as passed as a parameter, then further, Expression is Expression method of objectification, it represents the lambada Expression in the cases of the corresponding code, Expression through the Expression Tree data structure to store and describe the code, thus to give our ability to check the analysis code, like LINQ to SQL can analyze the Expression and the corresponding SQL statements, so the Expression is the foundation of the LINQ can realize, " https://zhuanlan.zhihu.com/p/47776558 But "on the right is the Expression, also is the object, it is Expression type of object," the Expression can be assigned to iquerayable interface? The cited the fifth floor of the knights templar 18 reply: CodePudding user response:
On the right side is expression, at the same time it is linq expressions, You need to know at the same time, will be compiled as lambda expressions, linq expression is: IQueryable Query=context. TableA. Where (Expression); Note, not give IQueryable Expression assignment, but Expression as an argument, after the Where operations, IQueryable CodePudding user response:
Well, the method is to return the iqueryable expression, eldest brother mean linq expression by the compiler to convert method, with method to return the iqueryable? refer to 7th floor of the knights templar 18 response: CodePudding user response:
refer to the eighth floor have water, cold response: well, method is to return the iqueryable expression, eldest brother mean linq expression by the compiler to convert method, with method to return the iqueryable? Quote: refer to 7th floor of the knights templar 18 reply: is CodePudding user response:
You don't have (from c... ). ToList () before, he just generates a SQL statement, No actual data query, CodePudding user response:
The references to the tenth floor zzuwxw response: you don't have (from c... ). ToList () before, he just generates a SQL statement, No actual data query, well, this I know, I just after the linq expression language to write how internal transformation, feel doubt, a Lord also said the above, is first converted into a method body, and then return to Iqueryable type CodePudding user response:
Inside was commissioned You can rewrite the above into DbContext. Custorm. Where (c=& gt; Arthur c. usName. The Contains (" useful ") & amp; & C.I d==2) F12 go in to see to know