這段代碼有區別嗎?鏈式linq查詢執行命令
var query = DbContext.Customers
.Where(<condition>)
.Include("Address");
而且
var query = DbContext.Customers
.Include("Address")
.Where(<condition>);
它遞延查詢,我不知道,是不是相同呢?或者在第二種情況下where
在Include
後執行?
謝謝。
順序無關緊要。 – wudzik
它們是等同的。在遍歷結果或調用ToList()之前,查詢不會執行。 – Oscar
在這種情況下,是的,但與LINQ實體和包括[它並不總是這個明確的削減](http://blogs.msdn.com/b/alexj/archive/2009/06/02/tip-22-how -to-make-include-really-include.aspx) –