I have few records like below in a collection where two records have same item name and description(example: sample1 and item1) but some other fields are different,
1.sample1 item1 Rule2 Rule2msg iteminfo2
2.sample1 item1 test1 testrule iteminfo1
I need to group above records in linq in such a way that output is like below ,
Sample1,
item1,
{
Rule2,
Rule2msg,
iteminfo2
},
{
testrule1 ,
testrulemsg,
iteminfo1
}
Basically what i am trying to achieve is since first two fields (itemName and Desc) is same , group them into single item and nest the remaining fields under the item so that item name is not duplicated and doesnt appear twice and appears as a single item. Any help is much appreciated
I have tried this
Itm.GroupBy(x => x.ITEM_NAME).Select(x => x.ToList()).ToList();
it groups items , but as two records not as single item as what i expect.