{
"ProductDMList":
[
{
"ProductID" : 1,
"CabinetList":
[
{
"Min" : 1,
"Max" : 12
}
]
},
{
"ProductID" : 1,
"CabinetList":
[
{
"Min" : 16,
"Max" : 100
}
]
}
]
}
I am using the below code to generate the above list.
List<ProductDM> productDMList = _orderRepo.GetSuggestedList(23, 12);
for (int i=0;i<productDMList.Count;i++)
{
productDMList[i].CabinetList.Add(new InventoryDM {
Min = productDMList[i].Min,
Max = productDMList[i].Max
});
}
public class ProductDM
{
public List<InventoryDM> CabinetList { get; set; }
public int ProductID { get; set; }
public double Min { get; set; }
public double Max { get; set; }
}
public class InventoryDM
{
public Double Min { get; set; }
public Double Max { get; set; }
}
How can I join the above 2 lists using ProductID
.
Ex : If the ProductID
is same I want to create one list and bind all cabiletLists
inside it.
Expected Output
{
"ProductDMList":
[
{
"ProductID" : 1,
"CabinetList":
[
{
"Min" : 1,
"Max" : 12
},
{
"Min" : 16,
"Max" : 100
}
]
}
]
}
I tried AddRange()
and Concat()
methods. But I was unable to get the above expected result.