c# - Selecting the value of a column not in GroupBy -
i need query selects column value info not grouped by. must grouping vkn number sum of invoicecount, want select firmname without grouping it.
public model1 { public int vkn {get; set;} public string firmname {get; set;} public string {get; set;} public string invoicecount {get; set;} } list<model1> temp = new list<model1> { /*adding value... */ }; var temp = m in temp grouping new { row.vkn, row.firmname} g select new { firmname = g.key.firname, vkn = g.key.vkn, invoicecountsum = g.sum(x => x.invoicecount), }
you can grouping row.vkn
, utilize aggregate function other fields not participated in grouping, if care result grouped collection (e.g. know firmname
unique per vkn
):
firmname = g.min(x => x.firmname)
c# linq
No comments:
Post a Comment