Home > front end >  How to transpose data in Linq?
How to transpose data in Linq?

Time:01-29

I get below data from Postgresql table, need to sum the ListDate field for each month and transpose. I tried this link enter image description here

CodePudding user response:

  var query = list
        .GroupBy(g =>
            g.ListDate.ToString()
        )
        .Select(group => new {
            MM = group.Sum(s => s.MM),
            FC = group.Sum(s => s.FC),
            AMS = group.Sum(a => a.AMS),
            KS = group.Sum(c => c.KS)
        });
  • Related