1
var a = (from t in unitOfWork1.Query<LedgerPosting>().Where(t => t.Oid == 1)
         group t by new { t.LedgerId.Oid, t.LedgerId.Name, t.LedgerId.OpeningBalance }
         into grp
            select new
                {
                    grp.Key.Oid,
                    grp.Key.Name,
                    grp.Key.OpeningBalance,
                    Debit = grp.Sum(t => t.Debit),
                    Credit = grp.Sum(t => t.Credit),
                    ClosingStock = (grp.Key.OpeningBalance + grp.Sum(t => t.Debit) - grp.Sum(t => t.Credit))
                }
        ).ToList();

在此我想通过条件,如果收盘股票为负,如收盘股票为 -2850,则价值应显示为类似2850 Cr ,收盘股票为正,如 2850,因此价值应显示为2850 Dr

怎么可能。?请帮帮我。

4

1 回答 1

1

您可以添加另一个.Select().

a.Select(x => Math.Abs(x.ClosingStock) + (x.ClosingStock < 0 ? " Cr" : " Dr"))
于 2018-11-03T16:54:55.923 回答