0

次の 2 つのクエリにパフォーマンスの違いはありますか?

CustomerProduct customerProduct = db.CustomerProducts.SingleOrDefault(p => object.Equals(p.Customer, this));

CustomerProduct customerProduct = (from p in db.CustomerProducts where object.Equals(p.Customer, this) select p).SingleOrDefault();

おそらく、さらに高速な別の方法がありますか?

4

1 に答える 1

1

コンパイルに関しては、同じコードにコンパイルする必要があります。Linq は、コンパイラが解釈する単なる構文糖衣です。そうは言っても、すべての linq クエリが期待どおりにコンパイルされるわけではなく、常にObjectQueryキャスト +ToTraceStringメソッドを使用して生成された SQL をチェックする必要があります。

于 2012-06-03T01:35:19.920 に答える