c# - linq group by and select multiple columns not in group by -


i'm trying select multiple columns not in group using linq - c#.

using linq, i'm trying group isnull(fieldone,''),isnull(fieldto,'') , select field_one, field_two, field_three each group. each row group return, want see numerous rows.

so far have following, can't seem select needed columns.

var xy = tablequeryable.where(             !string.isnullorempty(cust.field_one)             || ! string.isnullorempty(ust.field_two)             ).groupby(cust=> new { field_one= cust.field_one ?? string.empty, field_tow = cust.field_two  ?? string.empty}).where(g=>g.count()>1).asqueryable(); 

can pls?

you pretty there - missing select group:

var xy = tablequeryable     .where(!string.isnullorempty(cust.first_name) || ! string.isnullorempty(ust.lastname))     .groupby(cust=> new { first_name = cust.first_name ?? string.empty, last_name = cust.last_name ?? string.empty})     .where(g=>g.count()>1)     .tolist() // try work around cross-apply issue     .selectmany(g => g.select(cust => new {         id = cust.id     ,   cust.firstname     ,   cust.lastname     ,   cust.repid     })); 

select each group projection of fields want, while selectmany dumps results flat list.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -