One option, although not particularly elegant, may be as follows:
public class MyViewModel { public string UserId { get; set; } public FulltimeJob FulltimeJob { get; set; } public InternJob InternJob { get; set; } public IJob Job { get { return FulltimeJob ?? InternJob; } } }
This gives you easy access to common properties through the Job property, while maintaining access to any class properties.
You can then check which property is populated in your POST controller methods and act accordingly.
Morten mertner
source share