I want to use the updateModel in a controller that has no notice of the type of the view. I have different views that have different types but all have an ExternalBase class as inherited type.
So in my controller I always have a ExternalBase but the controller doesn't know the correct type.
On saving I call a method that gets the correct object but it returns this as an externalBase. The innertype is my correct type. If I hover over my object it is the type of the view that calls the save. Now if I call the updateModel on it it doesn't fill in the properties.
As an example:
// MyExternalBase is an empty class
The class person
public class Person
: MyExternalBase
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<TheParameters> Parameters { get; set; }
public Address Address { get; set; }
public TheParameters[] OtherParameters { get; set; }
}
public class Address
{
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public TheParameters Parameter { get; set; }
}
public class TheParameters
{
public string Parameter { get; set; }
}
In my controller on the Save I do the following:
MyExternalBase p = new Person();
UpdateModel(p, "Person", form.ToValueProvider());
Now the p doesn't fill up.
If I instead use Person p = new Person() Then it is no problem. But I want my controller to be independent of the view type.
Is this an error in the updateModel or something that just isn't possible? Or is ther a workaround for it?