Last post May 14, 2020 05:11 AM by email@example.com
Apr 09, 2020 06:16 AM|rajemessage|LINK
like in sqlserver we have following order of execution.
WITH CUBE or WITH ROLLUP
can i get the same msdn page where they have written the above thing for both sntaxs of linq.
Apr 09, 2020 09:37 AM|PatriceSc|LINK
Linq creates a SQL statement for you which then run on the db side so you likely won't find a separate documentation on that.
Still you can use Linq to create a wrong SQL statement that won't produce the result you expect (I remember to have seen someone doing that maybe with a contradictory distinct/ordering). Depending on which version you are using you can use https://cmatskas.com/logging-and-tracing-with-entity-framework-6/ to
trace generated SQL statements.
If you need further help, posting your Linq query and explaining how it differs from the expected result will be likely easier to deal with...
Apr 09, 2020 10:33 AM|Sean Fang|LINK
There is not a separate document like what you listed.
However, there are some information extracted from the
LINQ Document which might help you to understand LINQ better.
If you would like to know the order of the execution in linq, the first thing you should bear in mind is that
LINQ can be written by using declarative query syntax, but the
query syntax must be translated into method calls for the .NET common language runtime (CLR) when the code is compiled.
Therefore, asking the question about the execution order in LINQ is the same as asking the method execution order. These methods, like Where, Select, are extension method
You could find out all of the extension methods by clicking here
As you may already know why the select or group clauses are put at the end of the query syntax, it will return the final result as you execute other methods.
More information, you could spend time reading this document if you want to fully control the LINQ.
Hope this can help you.
May 14, 2020 05:11 AMfirstname.lastname@example.org|LINK
For EF order prior to the select does not matter. The LINQ query is converted to a SQL query and run and the SQL query. Specifically with Include when the following statements modify the structure of the query, but a where clause doesn't do that.
In other LINQ queries, LINQ-to-Objects, order can matter greatly as the query is not re-optimized the way SQL is and is simply processed from top to bottom, and some LINQ methods require previous methods to run to completion and process results before proceeding
to even the first element (OrderBy for example).