我是 LINQ 世界的新手。我正在尝试按如下方式计算总和-
var newSum = (from c in db.ExecutionDetails
join camp in db.CampaignDetailsPerExecutions
on c.SmsId equals camp.SmsId
where c.AmoCode == 5
&& c.DateTime between date1 and date2 //error
select camp.Poster).Sum();
&&
where 子句中的运算符出错(红色 curl 下划线)。
最佳答案
我希望你做错了,你必须像这样修改 where 子句:
where c.AmoCode == 5 &&
(c.DateTime >= date1 && c.DateTime <= date2)
如果要排除日期的上限和下限意味着从比较中删除 =
符号。
关于c# - LINQ where 子句中的多个条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40858916/