Is it good practice to use one model view inside of another one and how will AutoMapper work with it?
Example:
public class CustomerModelView
{
public string FullName {get;set;}
public string IList<OrderListModelView>(get;set;)
}
Is it good practice to use one model view inside of another one and how will AutoMapper work with it?
Example:
public class CustomerModelView
{
public string FullName {get;set;}
public string IList<OrderListModelView>(get;set;)
}
Yes, we do this quite often. In fact, in many cases we'll re-use ViewModels for partials, so in this case, you could have a partial for IList (or just a single one), so that multiple screens that display the common snippet re-use both the ViewModel and the partial view.
To do this in AutoMapper, you'll need to create a map for Customer -> CustomerModelView and Order -> OrderListModelView. There is nothing special you need to do for lists of items, you only need to map the element types.