私の理解では、次のコードです。
IQueryable<Things> things = dataContext.Things.Take(10);
if (fromDate > new DateTime(1980, 1, 1))
things = things.Where(a => a.InsertedDate > fromDate);
if (toDate < defaultDate)
things = things.Where(a => a.InsertedDate < toDate);
次のようなクエリになります(日付が条件を通過すると仮定します):
select top 10 [fields] from things
where inserteddate > '1/8/2010'
and inserteddate < '1/12/2010'
手順を踏んで、2 つの Where() ステートメントが設定されていることを確認しましたが、things.ToList() を呼び出すと、クエリが取得されます。
select top 10 [fields] from things
実際のクエリに組み込まれている 2 つの場所が実行されないのはなぜですか?