Tuesday, August 31, 2010

Insertion Using Entity Model



This is the Entity data Model NationalBankEntities3 in the program.
We are going to add Items into the table EmployeeDetail

Now we must write the code like below

NationalBankModel3.NationalBankEntities3 m = new NationalBankModel3.NationalBankEntities3();
NationalBankModel3.EmployeeDetail Emp = new NationalBankModel3.EmployeeDetail() { EmpName = "Smilu", EmpAddress = "EKM", EmpPhNo = "987654", EmpDob =Convert.ToDateTime("01/01/01") };

m.AddToEmployeeDetails(Emp);
m.SaveChanges();

Here AddToEmployeeDetails will be the method which will insert the data of the Entity we send.
SaveChages() will store the data into the table

No comments: