Should I be using some other attrbute that the List template respects, or am I stuck having to manually change the source to DisplayFor(m => m.someProperty) ?
I read in another thread a suggestion that ExpressionHelper.GetExpressionText should be used, but that’s not exactly what I’m looking for. I want the IDE’s Add View wizard to work for Lists as it does for the other scaffold templates, and I’m hoping there’s an attribute i could use on my properties to get that done.
It’s because the list could be empty and with an empty list you have no access to the an instance of the type you’re getting the display name for. As a result you lose typed access to the particular property you’re referencing.
For instance how would you know which property to use the display name for if you don’t have access to the object
You could write an extension method that would accept the model type of course but you’ll lose that typed access.
Though I don’t really recommend it.
small update – you could also access it via the model as well but still without typed access: