gpt4 book ai didi

c# - LINQ where 子句中的多个条件

转载 作者:太空宇宙 更新时间:2023-11-03 21:06:30 25 4
gpt4 key购买 nike

我是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com