可以使用 NOT IN 进行 LINQ to SQL 查询吗?
Can LINQ to SQL query using NOT IN?
例如,SELECT au_lname, state FROM author WHERE state NOT IN ('CA', 'IN', 'MD')
e.g., SELECT au_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD')
List<string> states = new List<string> { "CA", "IN", "MD" };
var q = from a in authors
where !states.Contains(a.state)
select new { a.au_lname, a.state };
或
var q = authors.Where( a => !states.Contains( a.state ) )
.Select( a => new { a.au_lname, a.state } );
这篇关于使用“NOT IN"的 LINQ to SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!