Linq group by query

前端 未结 2 497
遇见更好的自我
遇见更好的自我 2020-12-28 16:31

Trying to work out a linq query and was wondering if you guys could help.

I have a list of objects foo and each foo object has a list of <

相关标签:
2条回答
  • 2020-12-28 16:45

    Check it as well...

    var q = from e in Entries
              select new
              {
                   EntryID = e.EntryID,
                   EntryName = e.EntryName,
                   EntryDescription = e.EntryDescription,
                   VoterID = voterID,
                   Score = (int?)(from v in e.Votes
                                  where v.VoterID == voterID 
                                  select v.Score).FirstOrDefault()
    
    0 讨论(0)
  • 2020-12-28 16:53

    Looks like you want:

    var query = from foo in list
                from bar in foo.Bars
                group bar.Value by bar.Date into dates
                select new { Date = dates.Key, Sum = dates.Sum() };
    
    0 讨论(0)
提交回复
热议问题