我希望能够将 if 语句添加到 linq 查询中以添加第二个 LET。有谁知道这是否可能?谢谢
var query = from d in myList
group d by d.Date
into v
let dataSum = nv.Sum(x => x.Data)
select new MyObject(){ Date = nv.Key.Date, Data = dataSum}
//Invalid I know... but something like this is what I'm looking for
var query = from d in myList
group d by d.Date
into v
let dataSum = nv.Sum(x => x.Data)
if(secondaryData){ let dataSum2 = nv.Sum(x.Data2)}
select new MyObject(){ Date = nv.Key.Date, Data = dataSum}