3
例如我有人员,位置和personlocation表来链接这两个。我也有一个角色和人格表。实体框架多对多添加/删除对象问题
Tables:
Person (personid, name)
Personlocation (personid, locationid)
Location (locationid, description)
Personrole (personid, roleid)
Role (roleid, description)
EF会给我个人,角色和位置实体。
由于EF不会生成personlocation和personrole实体类型,因此它们不能在查询中使用 。
问题:如何添加Person对象并返回personid,然后将该id添加到Personrole表/关联中?
例如
Person p = new Person();
p.name = "John"
......
entity.AddToPersons(p);
for(var roleid in Roleid)
entity.AddtoRoles(roleid)?
THX,如果我想补充现有的角色是什么(例如,角色ID = 1,说明=“编辑器”) – Kiddo 2010-12-22 05:37:01