Not working
var repo = new Repository
MembershipUser currentUser = Membership.Provider.GetUser("John", true);
Employee employee = new Employee() { UserId = (Guid)currentUser.ProviderUserKey };
Company company = new Company() { Name = "my company" };
repo.Add(company);
company.Employees.Add(employee);
......
Solution
var repo = new Repository
MembershipUser currentUser = Membership.Provider.GetUser("John", true);
Employee employee = new Employee() { UserId = (Guid)currentUser.ProviderUserKey };
Company company = new Company() { Name = "my company" };
repo.Add(company);
Company.AddEmployee(employee)
......
So you need to make relation kind of manually. This implementation of AddEmployee looks like this:
public void AddEmployee(Employee employee)
{
this.employees.Add(employee);
employee.Company = this;
}
No comments:
Post a Comment