Prevent Entity Framework adding ORDER BY when using Include

c# entity-framework entity-framework-6 linq sql

Question

We have a question along these lines:

from x in db.Table.Include(x => x.Parent)
                  .Include(x => x.Parent.Relation)
                  .Include(x => x.Relation)
                  .Include(x => x.Children)
where /* some query */
select x

The issue is that when incorporating.Include(x => x.Children) , theORDER BY The produced SQL that Entity Framework adds a statement to makes the query take a very lengthy time to execute and looks like this:

ORDER BY [Project2].[Id1] ASC, [Project2].[Id2] ASC, [Project2].[Id] ASC, [Project2].[C4] ASC

The statement above is unaffected by adding orderby to the linq query other than by adding a second column to sort by, so it doesn't help either.

1
24
8/26/2014 11:29:00 AM

Accepted Answer

ZZZ_tmp
6
11/8/2014 8:06:44 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow