Look at the following code:
dbContext.AnEntity.Include("AnotherEntity").Where(e => e.ID = = id).ToList();
dbContext.AnEntity.Where(e => e.ID == id).Include("AnotherEntity").ToList();
Are the execution plans of these two expressions the same or different?
I hope it will be the same, especially because .Include (extended result set) is a separate category than .Where (a predicate) but: verification The only way is to test it and compare the generated SQL and performance.
According to the position of the where clause in the linq expression, is there a difference in performance?
Look at the following code:
dbContext.AnEntity.Include("AnotherEntity").Where(e => e.ID = = id).ToList();
dbContext.AnEntity.Where(e => e.ID == id).Include("AnotherEntity").ToList();
Are the execution plans of these two expressions the same or different?
In theory, no. In fact, you need to test according to the specific situation and the provider. For related (but slightly different) For example, in L2S for a long time, .Where (predicate).FirstOrDefault() and .FirstOrDefault (predicate) (have the same semantics) do not have the same behavior (especially related identity mapping shortcuts).
p>
I hope it will be the same, especially because .Include (extended result set) is a separate category than .Where (a predicate) But: the only way to verify is to test it and compare the generated SQL and Performance.