You must Sign In to post a response.
  • Category: .NET

    Creating nested list

    Hi there

    I am unable to create nested list( ex: category - sub category - sub sub category).How to sotr out this using c#.

    Then I will return it like

    [
    {
    "cat_code": "02",
    "cat_desc": "AUDIO",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null,
    "sub_cat": [
    {
    "cat_code": "22",
    "cat_desc": "AUDIO SYSTEMS",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "21",
    "cat_desc": "MAJOR AUDIO SEPARATES",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "20",
    "cat_desc": "MAJOR AUDIO SYSTEMS",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "23",
    "cat_desc": "MUSICAL INSTRUMENTS",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    }
    ]
    },
    {
    "cat_code": "01",
    "cat_desc": "VISION",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null,
    "sub_cat": [
    {
    "cat_code": "13",
    "cat_desc": "COMPUTER GAMES",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "10",
    "cat_desc": "TELEVISIONS",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "11",
    "cat_desc": "VIDEO",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    },
    {
    "cat_code": "12",
    "cat_desc": "VIDEO CAMERA/PHOTOGRAPHY",
    "exta_Desc": null,
    "mat_name": null,
    "matcode": null
    }
    ]
    }
    ]


    Thanks in advance.

    vijay.
  • #763106
    Hi,

    your question is not clear, we require few more details to understand your requirement and guide you in the same.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #763108
    Hi Naveen

    Thanks for your quick reply.

    I have a class with cat_code and cat_desc.
    Now with using this class .

    <category list>
    <subcat list>
    <subsubcat list>

    I hope you can understand,if not i will explain again.

    Thanks,
    vijay.

  • #763171
    Please provide the class structure or the database column details. Are you using lists to save the sub category and sub category.
    Miss. Jain
    Microsoft Certified Technology Specialist in .Net


Sign In to post your comments