0

已解决: IstBestellwert = grouped.Sum(o => (double)o.SollMenge * (double)o.Preis) 有效

我的 SQL 语句

 SELECT        ABId, SUM(Preis * IstMenge) AS IstBestellwert, SUM(Preis * SollMenge) AS SollBestellwert
    FROM            vChainStoreOrderingDetails
    GROUP BY ABId, FilialId
    HAVING  

  (ABId = 10) AND (FilialId IN (8, 140))

我在 linq 中的尝试

from csod in db.vChainStoreOrderingDetails
                                  where csod.Lieferdatum == lieferdatum && csod.ABId == ab.Id
                                  && filialen.Select(o => o.FilialId).Contains(csod.FilialId)
                                  group csod by new
                                  {
                                      csod.ABId
                                  } into grouped
                                  select new
                                  {
                                     test =grouped.Sum(o=> new {  test =((double) o.Preis * (double)o.SollMenge)})
                                  });

但选择部分不起作用。如何在 grouped.Sum() 内进行乘法运算,以便将乘法值相加

4

1 回答 1

2

IstBestellwert = grouped.Sum(o => (double)o.SollMenge * (double)o.Preis)

好吧,这似乎很有效

于 2009-10-26T14:18:37.607 回答