narsil/Tanshu.Accounts.Contracts/Data Contracts/Auth/Group.cs

37 lines
1.3 KiB
C#
Raw Normal View History

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<RoleGroup> RoleGroups { get; set; }
public virtual IList<UserGroup> UserGroups { get; set; }
public Group()
{
RoleGroups = new List<RoleGroup>();
UserGroups = new List<UserGroup>();
}
}
public class GroupMap : ClassMapping<Group>
{
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(); });
}
}
}