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 Group { public virtual Guid GroupID { get; set; } public virtual string Name { get; set; } public virtual IList RoleGroups { get; set; } public virtual IList UserGroups { get; set; } public Group() { RoleGroups = new List(); UserGroups = new List(); } } public class GroupMap : ClassMapping { public GroupMap() { Table("Auth_Groups"); Schema("dbo"); Lazy(true); Id(x => x.GroupID, map => map.Generator(Generators.GuidComb)); Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); }); Bag(x => x.RoleGroups, colmap => { colmap.Key(x => x.Column("GroupID")); colmap.Inverse(true); }, map => { map.OneToMany(); }); Bag(x => x.UserGroups, colmap => { colmap.Key(x => x.Column("GroupID")); colmap.Inverse(true); }, map => { map.OneToMany(); }); } } }