asp.net mvc - Update hierarchy model in Entity Framework -


i have 2 model classes:

request:

public partial class request {     public long id { get; set; }     public string username { get; set; }     public string description { get; set; }     public system.datetime createdate { get; set; }     public long deviceid { get; set; }     public bool isfinalized { get; set; }     public nullable<long> parentid { get; set; }     public virtual device device { get; set; } } 

device:

public partial class device {     public device()     {         this.requests = new list<request>();     }      public long id { get; set; }     public string serial { get; set; }     public string assetnumber { get; set; }     public system.datetime createddate { get; set; }     public virtual icollection<request> requests { get; set; } } 

i have update models use method

    public void update(requestviewmodel viewmodel)     {         var entity = _mappingengine.map<request>(viewmodel);         _requests.attach(entity);         _uow.entry(entity).state = entitystate.modified;     } 

but request model updated after calling update method. want update both models. please me.

attaching entity dbcontext, mark attached entity , dependencies (i.e. associated entities) unchanged. must tell ef entities new , entities modified.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -