ManyToManyMapping with Fluent Nhibernate
I have a table开发者_开发百科 USERS and GROUPS table.
I want to add another table UserGroups.
How can I map these tables.
Any example?
from my understanging you do it as:
class group{
public virtual int id(get;set;}
public virtual string groupName{get;set;}
}
class user{
public virtual int id{get;set;}
public virtual string name{get;set;}
public virtual group group{get;set;}
}
and in mapping file for user:
public class UserMap : ClassMap<user>
{
public UserMap()
{
Table("yourUserTable");
Id(x => x.Id).Column("Id");
Map(x => x.Name);
References(x => x.group).Column("group") --> referenceing mappign group
}
}
public class GroupMap : ClassMap<Group>
{
public GroupMap()
{
Table("yourUserTable");
Id(x => x.Id).Column("Id");
Map(x => x.Name);
References(x => x.group).Column("group") --> referenceing mapping group
}}
or HasManyToMany(x => x.group).Column("group") --> referenceing mapping group
精彩评论