LINQ to SQL Association 1 to N
How i can change this data mapping, if table UsersInRoles is relational table. (Example for, userId = 3, returns 5 rows).
private EntityRef<User开发者_高级运维InRoles> roles;
[Association(Storage = "UsersInRoles", ThisKey = "UserId")]
public UserInRoles Roles
{
get { return this.roles.Entity; }
set { this.roles.Entity = value; }
}
Thx
Use an EntitySet instead of an EntityRef.
private EntitySet<UserInRoles> _roles;
[Association(Storage="_roles", ThisKey="UserId", OtherKey="UserId")]
public EntitySet<UserInRoles> Roles
{
get
{
return this._roles;
}
set
{
this._roles.Assign(value);
}
}
精彩评论