I have an ASP.NET MVC app in which I am iteratin开发者_如何学运维g through a Linq result set. Each row in the result set contains a property which is an EntitySet itself. When I try to iterate through the inner result set, I get an error message: "Invalid object name EntitySetOfSubItem" when trying to load the page. How do I process this collection?
<% foreach item in Model { %>
... code
<% foreach subitem in item.EntitySetOfSubItems { %>
You would do it something like this:
<% foreach(YourType item in Model) { %>
... code
<% foreach(OtherType subitem in item.EntitySetOfSubItems) { %>
By typing the iteration variable, you inform the compiler what attributes are available on the subitem.
精彩评论