在SQL中会出现什么样的情况(SQL Server,如果你想要特别的话)?
// where people is a list of Person objects with property Name
bool bobs = people.All(p => p.Name == "Bob");
答案 0 :(得分:5)
您将检查是否有任何记录与标准不符:
not exists(select * from Persons where not Name = 'Bob')
由于C#和SQL之间的null
比较规则不同,如果字段允许,则需要一个空值条件:
not exists(select * from Persons where Name <> 'Bob' or Name is null)
答案 1 :(得分:3)
我不确定Linq将创建哪个查询,但SQL中的等效项是ALL
运算符:
'Bob' = ALL (SELECT name FROM people)