I have a viewmodel consisting of a handful of properties:
public class FooDataViewModel : IValidatableObject
{
/* Several Properties working as expected */
public ICollection<Foo> Foos {get; set;}
/* Validation working as expected */
}
Foo holds a few fields and works as expected:
public class Foo
{
/* Only a few basic properties, works as expected */
}
But I have some objects that are Foobar:
public class FooBar : Foo, IValidatableObject
{
/* Just a few more properties and some conditional validation */
}
I created a custom editor template for both Foo and FooBar. For my edit view, I simply use '@Html.EditorFor(m => m.Foos)' and editors for both Foo and FooBar are displayed. But when I submit to my HttpPost method, only Foo objects are created, and the FooBar specific data is lost. How can I make sure that that the FooBar objects are created?