Structure is basically like this:
Master:
Id
DocNo
Laws[]
Laws is as follows:
LawNo
Id
I want to group by DocNo and LawNo
expected dictionary keys is:
{DocNo, LawNo}
And the value is
Master
I tried this but key is not like the expected
master.GroupBy(x => new {x.DocNo, _LawNo = x.Laws.Select(y => y.LawNo).Distinct()});
Thanks
>Solution :
If I understand correctly, you can try to use SelectMany before using GroupBy, SelectMany let LawNo flatten as DocNo
master.SelectMany(x=>x.Laws,(x,y)=>new{x.DocNo,y.LawNo})
.GroupBy(x=> new {x.DocNo,x.LawNo});