d45*_*456 7 sql linq sql-server sql-server-2012
这在SQL中会是什么样子(SQL Server,如果你想特别的话)?
// where people is a list of Person objects with property Name
bool bobs = people.All(p => p.Name == "Bob");
Run Code Online (Sandbox Code Playgroud)
您将检查是否有任何记录与条件不符:
not exists(select * from Persons where not Name = 'Bob')
Run Code Online (Sandbox Code Playgroud)
由于nullC#和SQL之间的比较规则不同,如果字段允许,则需要空值的条件:
not exists(select * from Persons where Name <> 'Bob' or Name is null)
Run Code Online (Sandbox Code Playgroud)