public class APIBillingHistory
{
public List<APIBillingHistoryDetails> BillingHistoryDetails;
}
public class APIBillingHistoryDetails
{
public List<APIBillingHistoryPaymentType> PaymentType;
public string BillId;
}
public class APIBillingHistoryPaymentType
{
public string Description;
public Decimal Principal;
}
I have a class of nested list objects. I would like to merge respective PaymentList collection to its parent list APIBillingHistoryDetails
For example:
APIBillingHistory
-----BillingHistoryDetails
Bill ID : 123
----PaymentType
Description : "A"
Principal : 100
----PaymentType
Description : "B"
Principal : 200
-----BillingHistoryDetails
Bill ID : 123
----PaymentType
Description : "A"
Principal : 150
----PaymentType
Description : "B"
Principal : 300
Let's say I have sample date specified above. I would like to have resulted in the following format. Here I am merging PaymentList by adding Principal attribute for each Description values if they have same bill Id
The output should look like this:
APIBillingHistory
-----BillingHistoryDetails
Bill ID : 123
----PaymentType
Description : "A"
Principal : 250
----PaymentType
Description : "B"
Principal : 500