using System; using System.Runtime.Serialization; using System.Collections.Generic; using Tanshu.Accounts.Contracts; using NHibernate.Mapping.ByCode.Conformist; using NHibernate.Mapping.ByCode; namespace Tanshu.Accounts.Entities.Auth { public class Role { public virtual Guid RoleID { get; set; } public virtual string Name { get; set; } public virtual IList Groups { get; set; } public Role() { Groups = new List(); } } public class RoleMap : ClassMapping { public RoleMap() { Table("Auth_Roles"); Schema("dbo"); Lazy(true); Id(x => x.RoleID, map => map.Generator(Generators.GuidComb)); Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); }); Bag(x => x.Groups, colmap => { colmap.Key(x => x.Column("RoleID")); colmap.Inverse(true); }, map => { map.OneToMany(); }); } } }