I have the following snipped inside a Razor-file:
<td>@item.Mottakere.All(q => {
@q.Epost <br />
})</td>
Where @item is a object from a foreach ... Model.ToList() and @item.Mottaker is a List inside this object.
I know this doesn't work, mostly because All expects a bool, and also because I can't inline razor in a lambda this way... But is there any way I could force this kind of function开发者_运维问答ality? Or should I just do a normal nested foreach ?
I invite you to checkout Templated Razor Delegates.
All doesn't expect bool, but it returns true when the given lambda is true for every item in the list - for example Are all apples in the list red?
In your case, when you want to output the elements in Mottakere, you'll have to use another foreach or use some helper method. For example see this.
加载中,请稍侯......
精彩评论