DbContext -> DbSet -> Where clause is missing (Entity Framework 6)

后端 未结 2 1609
北海茫月
北海茫月 2021-02-07 15:43

I\'ve read some tutorials with entity framework 6...

The basics are easy.

using (var context = new MyContext())
{
    User u = context.Users.Find(1);
}
<         


        
2条回答
  •  孤街浪徒
    2021-02-07 15:57

    Thanks to @Grant Winney and @Joe.

    Adding using System.Linq; to the namespace/top of the document where i'm tring the code above fixed the problem.

    And using the line above it works for the first item of the list.

    User user = (select user from context.Users where user.Username == username select user).First();
    

提交回复
热议问题