How to render the properties of the view model's base class first when using ViewData.ModelMetadata.

Posted by Martin R-L on Stack Overflow See other posts from Stack Overflow or by Martin R-L
Published on 2010-05-05T09:01:04Z Indexed on 2010/05/05 21:08 UTC
Read the original article Hit count: 364

Filed under:
|

When I use the ViewData.ModelMetadata.Properties in order to loop the properties (with an additional Where(modelMetadata => modelMetadata.ShowForEdit && !ViewData.TemplateInfo.Visited(modelMetadata))), and thereby create a generic edit view, the properties of the view model's base class are rendered last.

Is it possible to use a clever OrderBy() or is there another way to first get the properties of the base class, and then the sub class'?

Reverse won't do the trick since the ordering of each class' properties is perfectly fine.

A workaround would of course be composition + delegation, but since we don't have mixins, it's too un-DRY IMHO, why I seek a better solution if possible.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about c#4.0