Linq2Entities: Update relationship?
Posted
by Poku
on Stack Overflow
See other posts from Stack Overflow
or by Poku
Published on 2010-04-20T05:50:51Z
Indexed on
2010/04/20
5:53 UTC
Read the original article
Hit count: 236
Hey,
How do i create a new row in a table which have a relationship with another table?
I have an Employees table and a EmployeeProjects table. One Employee can have 1-* EmployeeProjects.
Now i want to create a new EmployeeProject which relates to an Employee. How do i do this?
Here is want i have tried so far:
var ep = new EmployeeProjects();
ep.JobNo = jobNo;
employee.EmployeeProjects.Add(ep);
var originalEmployee = GetEmployee(employee.Id);
_entities.ApplyPropertyChanges(originalEmployee.EntityKey.EntitySetName, employee);
_entities.SaveChanges();
© Stack Overflow or respective owner