I have a list which I get from a database. The structure looks like (which I'm representing with JSON as it's easier for me to visualise)
{id:1 value:"a" }, {id:1 value:"b" }, {id:1 value:"c" }, {id:2 value:"t" } As you can see, I have 2 unique ID's, ID 1 and 2. I want to group by the ID. The end result I'd like is
{id:1, values:["a","b","c"], }, {id:2, values["g"] } Is this possible with Linq? At the moment, I have a massive complex foreach, which first sorts the list (by ID) and then detects if it's already been added etc but this monstrous loop made me realise I'm doing wrong and honestly, it's too embarrassing to share.
.ToLookupor.GroupBy