3
linq-to-sqlでは、どちらの場合でも評価するのがより効率的ですばやくなると期待されますか?彼らは同じSQLにコンパイルしますか?これらの例の中から選択する際に考慮すべき他の要素はありますか?2つの等価性検査を1つにするか、その逆の場合効率を
context.Events
.Where(evt => evt.Date <= endDate && evt.Date > startDate);
または...
context.Events
.Where(evt => evt.Date <= endDate)
.Where(evt => evt.Date > startDate);
重複した質問リンクがこれを完全に回答してくれてありがとうございます。 – gingerbreadboy
最終的にそれらは両方とも同じSQLに変換されるので、実際の違いはありません。 – juharr
興味深いことに、誰かがもう一度それを開いたので、OPが反対であっても重複を拒否しました。だからここにいくつかの関連(または重複):http://stackoverflow.com/questions/23674778/linq-differences-between-single-where-with-multiple-conditions-and-consecutiveまたはhttp://stackoverflow.com/質問/ 6359980/proper-linq-where-clause?noredirect = 1&lq = 1またはhttp://stackoverflow.com/questions/664683/should-i-use-two-where-clauses-or-in-my-linq-クエリ(誤解を招いています) –