I have three Models something like this:
public class Section
{
public string Id {get; set;}
public SubSection[] SubSections {get; set;}
public Item[] Items {get; set;}
}
public class SubSection
{
public string Id {get; set;}
public string sectionId {get; set;}
public Item[] Items {get; set;}
}
public class Item
{
public string Id {get; set;}
public string sectionId {get; set;}
}
Now when I get the result back I get back list of Sections and Items and would like to merge these two lists to put it into the above Models.
Everything is connected with Section Id; determining where the item goes in SubSection or directly under section and the subsections go under section array.
Is there a good way to do this using Linq?
Example:
Item { id = "123", sectionId = "456"}
Item {id = "234", sectionId = "786"}
SubSection {id = "211", sectionId = "786", Items = null}
SubSection {id = "210", sectionId = 456", Items[] = new Item() {"123"}}
Section {id = 786, subsections[] = null, items[] = new Item() {"234" }}
Section {id = 456, subsection[] = new SubSection { id = 210}, items = null}