开发者

NHibernate Attributes Mapping List

I'm a new NHibernate developer. I'm using attributes and not map files and I have configured the application to create the tables automatically.

I Have two classes , Group and User.

Withing the Group class I have a list of users

public class Group
{
    [NHibernate.Mapping.Attributes.Id(Name = "GroupId")]
  开发者_Python百科  [NHibernate.Mapping.Attributes.Generator(Class = "guid")]
    public virtual Guid GroupId { get; set; }
    // What Attributes do I place here
    public virtual List<User> Users { get; set; }
}

I can't find the right attributes so that there will be two tables that have one to many relation.

Can anyone help?

Thanks, Ronny


[ManyToMany], [OneToMany] or [ManyToOne] (those linked docs are fairly useless though) depending on how you want it setup. Probably [OneToMany], and then the same on a User.

You could avoid the pain by using the Fluent NHibernate library instead, if you haven't already tried it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜