LINQ语句不工作
问题描述:
我有一个LINQ方法好心看它告诉什么地方错了..........LINQ语句不工作
openQuery = from open in output.result.data
**where open.activity.Contains(open.activity.Where(act => act.action == Action && act.timestamp.Date >= Convert.ToDateTime(DateTime.Now.Date.AddDays(-24))).FirstOrDefault())**
select open;
当where
条件比openQuery
回报的评论在REsultView领域,但是当我去评论它
答
如果你只是执行where子句内的查询它提供了一个enumerationfield错误:
open.activity.Where(act => act.action == Action
&& act.timestamp.Date >= Convert.ToDateTime(DateTime.Now.Date.AddDays(-24)))
什么哟你得到了吗?
答
这应该适合你。您不需要使用Contains()方法。
openQuery = from open in output.result.data
where open.activity.action == Action && open.activity.action.timestamp.Date >= Convert.ToDateTime(DateTime.Now.Date.AddDays(-24)))
select open;
+0
它给出了以下错误:'System.Collections.Generic.List
它返回的错误:错误\t \t无法转换lambda表达式“BOOL”类型,因为它不是一个委托类型 –
你是如何执行的呢? – Richard
对不起,但我不明白你的问题 –