Replace Entity Framework object

Posted by majkinetor on Stack Overflow See other posts from Stack Overflow or by majkinetor
Published on 2010-03-16T09:40:41Z Indexed on 2010/03/16 9:46 UTC
Read the original article Hit count: 187

Filed under:
|

In MVC app, I am having this big object that is used in classic view/edit/create pattern.

When user edits the object I save it as:

  public bool SetMyObject(MyObject newObject) {
     MyObject current = GetObjectById(newObject.Id);
     current.Prop1 = newObject.Prop1
     ...
     current.PropN = newObject.PropN
     db.SaveChanges();
  }

MyObject is pretty big so I am wondering is there any better way to do this, not involving per-property assignments. For instance something along the lines db.MyObject.UpdateObject(current, tnew).

Ty.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about mvc