[英]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)
如果要排除日期的上限和下限,則意味着從比較中刪除=
符號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.