Suppose I have the view models below.
public class CustomerListViewModel {
public IEnumerable<CustomerViewModel> Customers { get; set; }
}
public class CustomerViewModel {
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public int Age { get; set; }
}
I want to display the list of Customers in my view inside a for-each loop. I also want to use DisplayFor to show the values with conventions applied (as opposed to just outputting the property as-is: customer.Age). With ASP.NET MVC, I used to just ignore the lambda variable in my expression (as was similarly discovered by the asker of this question).
<% foreach (var customer in Model.Customers) { %>
...
<li><%: this.DisplayFor(m => customer.Age) %></li>
<% } %>
However, I get an error with FubuMVC if I do this.
Unable to cast object of type 'System.Reflection.RtFieldInfo' to type 'System.Reflection.PropertyInfo'.
Must I use a partial to render each customer with DisplayFor appropriately?
Thanks in advance!