C# Difference between First() and Find()

前端 未结 5 1532
花落未央
花落未央 2020-12-08 19:08

So I know that Find() is only a List method, whereas First() is an extension for any IEnumerable. I als

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 19:16

    1- Find() returns Null if the entity is not in the context but First() will throw an exception
    2- Find() returns entities that have been added to the context but have not yet been saved to the database

提交回复
热议问题