views:

67

answers:

1

We are working with entities in our MVC controllers which are passed to strongly typed views.

How do we re-instantiate these entities in the controller with updated data when the form is posted in the view? The form does not contain all the fields of the entity so all of the data needed to re-instantiate the entities won't be there in the model binding. Only a partial set of data will be submitted.

I dont wont to reload the entities based on key values prior to updating them with posted values as this is 1) Inefficient 2) Prevent optimistic concurrency with my POCO objects in the Entity Framework if I dont keep the value original RowVersion concurrency field

But my question is is this the recommended way?

This question could apply to any entities that contain data that isnt re-submitted in the view and you dont want to reload the entities.

Thanks

+2  A: 

I would just make the request to the database to get the entity again, and if you're worried about concurrency, then check a version number or something. If your main concern is inefficiency, then just re-query the DB for now, and if it truly ends up being inefficient, then you can use some type of cache... what other options are there?

Josh Pearce
Thanks. It looks like this will be the way to go ...
Steve Ward