HugoHiasl
asked on
MVC Razor how to loop through nested data?
Hi,
I have a data structure with nested location objects and in every level of the loction object is it possible to have resources assigned.
Now I would like to render it using RAZOR in a nested way. Normally I would use recursive methods for it. But I don't think that's possible with RAZOR
what is the best practice for something like this?
I have a data structure with nested location objects and in every level of the loction object is it possible to have resources assigned.
[u]Location-Object[/u]
Id
ParentLocation
LocationName
[u]Resource-Object[/u]
Id
LocationId
ResourceName
--Location
-- Location
-- Resource
-- Resource
-- Location
-- Resource
Now I would like to render it using RAZOR in a nested way. Normally I would use recursive methods for it. But I don't think that's possible with RAZOR
what is the best practice for something like this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Normally, once you are inside a Razor block you don't need to prefix your code with an @. However, in my testing (and research) I found that when you call one helper from another you need to prefix the call with the @. This is why lines 9, 21, and 28 have the leading @.
ASKER