I'm looking to group a list based on a list within that list itself, given the following data structure:
public class AccDocumentItem
{
public string AccountId {get;set;}
public List<AccDocumentItemDetail> DocumentItemDetails {get;set;}
}
And
public class AccDocumentItemDetail
{
public int LevelId {get;set;}
public int DetailAccountId {get;set;}
}
I now have a List<AccDocumentItem>
comprised of 15 items, each of those items has a list with variable number of AccDocumentItemDetail
's, the problem is that there may be AccDocumentItems
that have identical AccDocumentItemDetails
, so I need to group my List<AccDocumentItem>
by it's AccDocumentItemDetail
list.
To make it clearer, suppose the first 3 (of the 15) elements within my List<AccDocumentItem>
list are:
1:{
AccountId: "7102",
DocumentItemDetails:[{4,40001},{5,40003}]
}
2:{
AccountId: "7102",
DocumentItemDetails:[{4,40001},{6,83003},{7,23423}]
}
3:{
AccountId: "7102",
DocumentItemDetails:[{4,40001},{5,40003}]
}
How can I group my List<AccDocumentItem>
by it's DocumentItemDetails
list such that row 1 and 3 are in their own group, and row 2 is in another group?
Thanks.