LINQ where 子句中的多个条件

Multiple condition in LINQ where clause

我是 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 子句中的运算符给出错误(红色卷曲下划线)。

我希望你做错了,你必须像这样修改 where 子句:

where c.AmoCode == 5 && 
     (c.DateTime >= date1 && c.DateTime <= date2)

如果要排除日期的上限和下限意味着从比较中删除 = 符号。