LINQ哪里有条款疑问

4 c# linq clause where

我已经在Linq中尝试了一个where子句来获取有关User那些过去ActiveAllowLogin现实的人的详细信息.

那么如何将表值(两者都是布尔值)与true或false进行比较?

Jon*_*eet 14

只需使用以下内容:

var query = from user in context.Users
            where user.Active && user.AllowLogin
            select user;
Run Code Online (Sandbox Code Playgroud)

或者,您可以在没有查询表达式的情况下编写相同的查询:

var query = context.Users.Where(user => user.Active && user.AllowLogin);
Run Code Online (Sandbox Code Playgroud)