使用LINQ如何让这个查询返回除字符串数组中的所有状态?
string[] states = { "FL", "CA", "IN", "AL", "MI" };
var headers = (from h in db.Headers
where h.State != states.Any()
select new
{
description = h.Description,
state = h.State
});
Run Code Online (Sandbox Code Playgroud)
你可以试试这个:
var headers = (from h in db.Headers
where !states.Contains(h.State)
select new
{
description = h.Description,
state = h.State
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
164 次 |
| 最近记录: |