Entity Framework Find vs. Where

前端 未结 1 1711
清酒与你
清酒与你 2020-12-03 00:54

Is there a significant difference between .Find(id) and .Where(x = >x.Id == id) that should compel me to use .Find() over .Wh

相关标签:
1条回答
  • 2020-12-03 01:33

    The point is that find starts by searching in the local cache of the context and then, if no match, sends a query to the db.

    where always sends a query to the db.

    With EF 4.*, I used to think that sql generated by find was too complex and, in some cases, leads to a performance issue. So I always use where even with EF 5. I should check the sql generated by find with EF 5.

    So in the paper, find is better because he uses the cache.

    0 讨论(0)
提交回复
热议问题