Fetching Parent Child records to N - Level RRS feed

  • Question

  • Hi ,

    i have a custom object with 4 level of parent :-> Child 1 :-> Child 2:-> Child 3 :-> Child 4

    parent,Child 1,Child 2,Child 3 and Child 4 has the same into ID & Value . my custom object structure is (which will have the result from Database and in IQueryable collection



    as all the objects has same information i have created one common class

    class EntityItem

    { public int ID { get; set; } public string Value { get; set; } public List<EntityItem> Children}


    now by using the Linq to SQL i want to populate these parent & child information in EntityItem Collection

    can any one help on this

    Thank You Verty Much


    Thursday, July 29, 2010 12:52 PM

All replies

  • Hello,

    I don't know why you created so many tables in database (imagine there are 100 children, how to deal with?) To better oganize the relationship between tables, I suggest you create a table which has a tree structure. Then there's no need for the extra common class, you can get all the children for a particular entity.

    hope this helps:)

    Thursday, August 5, 2010 6:21 AM
  • ok, it will be fine if it works at least 3 levels , just consider this samples


    Countries :-> States :-> County


    please help out if any solutions

    Thanks , Raj
    Monday, August 9, 2010 6:12 PM