0
shopId    shopname   ProductcategoryID categoryname   ProductName
-----    ---------    ---------           -----       ---------
  1      test1        1                   Value1      testpd1
  1      test1        1                   Value1      testpd2
  1      test1        2                   Value2      testpd3
  1      test1        2                   Value2      testpd4
  2      test2        1                   Value3      testpd5
  2      test2        1                   Value3      testpd6
  2      test2        2                   Value4      testpd7
  2      test2        2                   Value4      testpd8

My Product Storedprocedure output is above sql flat result from this i want to convert into my class objects.

class Shop
{
   int shopid{get;set;}
   string shopname{get;set;}
   list<ProductCategory> PC{get;Set};
}

class ProductCategory
{
   int Productcategoryid
   string categoryname{get;set;}

   list<ProductName> PN{get;set;}
}

class ProductName
{
   int productID{get;set;}
   string productname{get;set;}
}

how can i convert above sqlflat result into my nestedobjects as shown above. the final object should be a list of shop objects which it self contains category objects and category objects contains product object.

nLearn
  • 55
  • 1
  • 5

1 Answers1

0

why you want to convert datatable to list? is it because of performance ?

You can try this. This is not for nested table but may be you can start with this.
Convert DataTable to List

Community
  • 1
  • 1
user2463514
  • 273
  • 1
  • 4
  • 19