开发者

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);
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜