Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a requirement to display the output list as below dynamically:

XML
<ul>
    <li>
        Category 1
        <ul>
            <li> Category 1 Page 1</li>
        </ul>
    </li>
    <li>
        Category 2
        <ul>
            <li>
                Category 2 List 1
                <ul>
                    <li>Category 2 List 1 Page 1</li>
                    <li>Category 2 List 1 Page 2</li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        Category 3
        <ul>
            <li> Category 3 Page 1</li>
            <li>
                Category 3 List 1
                <ul>
                    <li>Category 3 List 1 Page 1</li>
                    <li>Category 3 List 1 Page 2</li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        Category 4<ul>
            <li> Category 4 Page 1</li>
        </ul>
    </li>
</ul>


Am using 2 tables as below :
Table 1 Name : Category
Columns : Category, Parent Category {parent child relationship to at max 3 levels of nesting}

For the categories which dont have a parent will have a value null.

Table 2 Name : Category Pages Mapping
Columns : Category , PageName

Any help on building up the query using linq to sql or lambda expressions? I am using mvc 5 and ef 6.
Posted
Updated 23-Jul-15 0:47am
v2
Comments
jyo.net 24-Jul-15 2:02am    
see http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/nested-collection-models-in-mvc-to-add-multiple-phone-number/

It may help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900