Is there a way to handle this without custom Model Binding?
public class MyViewModel {
public string UserId { get; set; }
public IJob Job { get; set; }
}
public interface IJob {
public long Id { get; set; }
public string CompanyName { get; set; }
}
public class FullTimeJob : IJob {
// omitted for brevity
}
public class Internship : IJob {
// omitted for brevity
}
The issue I'm having is I get an error in the default model binder because it doesn't understand which implementation of IJob to instantiate. When I created the MyViewModel, I set an instance of FullTimeJob into its Job property. I guess ASP.NET can't retain the implementation type?
What's the best practice solution for this?