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

后端 未结 2 510
鱼传尺愫
鱼传尺愫 2021-02-07 15:46

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 16:08

    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();
    

提交回复
热议问题