asp.net mvc - Editing and Updating Entity Framework entity in ASP .NET MVC -
I have a unit framework unit called "ABC" (Attribute ID and Title).
Look at the update record, I've added the ID as a hidden field and the headline text box.
The controller looks something like this:
Public Action Update Action (ABC OBJ)
Let me do everything right and fair in obj Meets - i.e., title and id.
To update the records in the database now, I read the parent unit:
var = (base.context.ABC in x where x.id = = Obj.id). Single ();
To reflect changes in the original now, I think the update should be modeled:
this.TryUpdateModel (original);
I get an error: | ... stating that the column ID can not be changed.
Property 'id' is part of important information about the object and can not be modified.
I do not want to manually specify properties on the original object back.
The second option can be:
TryUpdateModel (original, new string [] {"title"}, form.ToewoProver ());
But I hate string - my object is like 20 characteristics: |
Can someone recommend a better pattern of doing this?
Example:
UpdateModel & lt; MyModel & gt; (Model, x => x.PropertyFromMyModel_1, x => x.PropertyFromMyModel_2);
Comments
Post a Comment