Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

i'm have a parent table Employee and a child table "address" and "Department".

First i'm creating

C#
MainDbContext appEnt=new MainDbContext();
protected override Emplyee CreateDataObject(Employee ty)
       {
           ty = appEnti.Employee.Add(ty);
           appEnt.SaveChanges();
           return ty;
       }

       protected override Employee UpdateDataObject(Employee ty)
       {
           var storety = appEnt.Employee.Find(ty.ID);
           appEnt.Entry(storety).CurrentValues.SetValues(ty);
           appEnt.SaveChanges();
           return ty;
       }



Here Employee table consists of Address Table as a relation its iD and Departments is also a different table these two tables having relation with parent table Employee. at the time of creation i am able to save entire data of child tables also but when i m trying to save the updated data im unable to save it only the parent table data gets saved. can any one help me out. UpdateDateobject which im using for updating and CrreateDataObject for creation.


Thanks
Posted
Updated 10-Aug-15 21:39pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900