Linq To Entities - Any VS First VS Exists

后端 未结 5 1183
滥情空心
滥情空心 2021-01-07 21:36

I am using Entity Framework and I need to check if a product with name = \"xyz\" exists ...

I think I can use Any(), Exists() or First().

Which one is the b

5条回答
  •  无人及你
    2021-01-07 22:03

    Any() and First() is used with IEnumerable which gives you the flexibility for evaluating things lazily. However Exists() requires List.

    I hope this clears things out for you and help you in deciding which one to use.

提交回复
热议问题