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();

In this i want to pass if condition like if closing stock is negative like closing stock is -2850 so value should be display like 2850 Cr and closing stock is positive like 2850 so value should be displayed like 2850 Dr.

How can it Possible.? Help me Please.

Peter Szekeli
  • 2,712
  • 3
  • 30
  • 44
Rashmi
  • 31
  • 4

1 Answers1

1

You can just add another .Select().

a.Select(x => Math.Abs(x.ClosingStock) + (x.ClosingStock < 0 ? " Cr" : " Dr"))
shamp00
  • 11,106
  • 4
  • 38
  • 81