Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to do a group by but i'm getting this error when doing so

Element.GroupBy(x => new { x.Select(y=>y.Id)}



Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access


What I have tried:

<pre>Element.GroupBy(x => new { x.Select(y=>y.Id)}
Posted
Updated 4-Sep-20 19:45pm
v4

1 solution

That's because it has no idea what you are trying to do - there is no obvious grouping data there. Did you mean something like:
C#
myCollection.GroupBy(c => c.PropertyToGroupBy).Select(g => new(g.Key));
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900