Last Rows Grandtotals RRS feed

  • Question

  • var query = (from x in db.ViewFaturats select new { A = x.Data, B = x.Emri,C = x.VleraTVSH,D = x.Totali })
       .Concat(from y in db.ViewShitjaFaturims select new { A = y.Data, B = y.Emri,C = y.VleraTVSH, D = y.Totali });

    I like in las rows to have grand totals for  Column  only  C and D

    how can I do this?


    Thursday, July 2, 2020 11:37 AM

All replies

  • Hi DataRks,
    You can use group and sum to get totals of C and D column.
    Here is a simple code example you can refer to.

    from p in db.ViewFaturats
    group p by 1 into g
    select new
        SumC = g.Sum(x => x.VleraTVSH), 
        SumD = g.Sum(x => x.Totali) 

    Here is a similar thread you can refer to.
    [Get sum of two columns in one LINQ query]
    Best Regards,
    Daniel Zhang

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, July 3, 2020 7:16 AM