santosh behera

santosh behera

  • NA
  • 92
  • 11.8k

Create a class of hierarchy list from list using LINQ

Apr 18 2016 4:51 AM
Hi
i have the below data , employee column consider as parent and each employee have invoice as child and each invoice have invoicedetails as subchild. i have binded this data into a list of class. now i want create hierarchy list from this list using LINQ

parent--->child--->subchild
Employee--->Invoice--->InvoiceDetails

List Data:

Employee invoice InvoiceDetails jan feb Mar Apr
E1 I1 ID1 1 2 10 5
E1 I1 ID2 1 3 11 6
E1 I1 ID3 1 4 12 7
E1 I2 ID1 1 5 13 8
E1 I2 ID2 1 6 14 9
E1 I2 ID3 1 7 15 10
E2 I1 ID1 1 8 16 11
E2 I1 ID2 1 10 17 12

Output :

E1
--I1
------ID1 1 2 10 5
------ID2 1 3 11 6
------ID3 1 4 12 7
--I2
------ID1 1 5 13 8
------ID2 1 6 14 9
------ID3 1 7 15 10
E2
--I1
---------ID1 1 8 16 11
---------ID2 1 10 17 12

Thanks

Answers (1)