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

35 lines
1007 B
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 Role
{
public virtual Guid RoleID { get; set; }
public virtual string Name { get; set; }
public virtual IList<RoleGroup> Groups { get; set; }
public Role()
{
Groups = new List<RoleGroup>();
}
}
public class RoleMap : ClassMapping<Role>
{
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(); });
}
}
}