代码:
public static List<ExpressionListDictionary> GetAmounts()
{
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
LinqMetaData meta = new LinqMetaData(adapter);
var now = DateTime.Now;
var endDate = now;
var startDate = now.AddMonths(-3);
var datas = ( from test in meta.Test
where test.DateCreated >= startDate && test.DateCreated <= endDate && test.ViaTo > 0 && test.Cancelled == 0
select MonthOfYear(test.DateCreated)); // how can I get the month name correctly?
}
}
Cancelled
是bool TestEntity.Cancelled
我在where
声明中收到错误。我该如何修理它?
答案 0 :(得分:3)
您上次&&
之后的陈述不对,您需要==
进行比较,而不是=
=
在C#中做任务,这就是为什么抱怨:
&& test.Cancelled == 0
由于Cancelled
为bool
,您必须将true
或false
置于比较中
答案 1 :(得分:1)
根据您的评论,由于Cancelled
是一个布尔属性,为什么您要尝试将其与0
进行比较?你可以这样做: -
&& test.Cancelled
或&& !test.Cancelled
否定案例。
答案 2 :(得分:1)
您应该更正:
&& test.Cancelled = 0
进入以下内容:
&& !test.Cancelled