I am having trouble trying to think that the best way is to recreate the database object in the controller action.
I want to use ModelBinders, so in my action I have access to the object through the parameter, instead of having to repeat the code to get the object from the database based on the identifier parameter. Therefore, I thought about ModelBinder making a data-level call to get the original object (or creating a new one if it does not exist in the database), and then associating any properties with the database object to update it. However, I read that ModelBinders should not make database queries (first comment of this article ).
If the ModelBinder does not have to execute the database query (so just use DefaultModelBinder), then what about database objects that have properties that are other db objects? They will never be assigned.
Saving the object after the user has edited it (properties 1 or 2 are edited in the view), there will be no data for the ModelBinded object, so saving it like this will cause the data in the database to be overwritten with invalid values, or NOT-NULL.
So what is the best way to get an object in a controller action from a database associated with form data submitted back from a view?
Pay attention to the use of NHibernate.