I have two types of contact objects. One that has only an email address, and one that manages this and includes fields for the mailing address.
I am trying to get my controller action to work with any type of contact and still stumbled upon two problems ...
When validation occurs using DataAnnotations, its validating fields are from the base class before the fields from the subclass. I really want this to happen in reverse order. Is there a way to reinstall the order? Usually, of course, you can simply change the order of the fields, but if the fields are in different classes, this is not possible.
I found that I need to create the model manually, because apparently, the middleware wants to create the specific type specified in the action parameter by default. When I try and bind the model manually using "UpdateModel", even then its only binding the fields of the base type (the base type is the type returned by my factory contact).
Does anyone have any advice on this? It seems that I will have to go back to the spaghetti code, which constantly evaluates the type of contact on which it works.
Greetings, Jan.
source
share