Dears,
I've got the domains about the app-rights-Role
relations:
1. A role has a Rights
2. a Rights has a Menu and a RightsCode , the RightsCode value is like
1111,1101 ,etc, it means if have the CRUD rights
and i have two problem:
1. I could not delete the Menu's record
firstly.
2. The Rights's Id is not a native Id
-----domain code--------------------------------
public class Role
{
public int Id { get; set; }
public string RoleName { get; set; }
public IList<Rights> Rights { get; set; }
}
public class Rights
{
public int Id { get; set; }
public Menu Menu { get; set; }
public string RightsCode { get; set; }
}
public class Menu
{
public int Id { get; set; }
public string MenuName { get; set; }
}
----------- mapping code---------------------
var orm = new ObjectRelationalMapper();
orm.Patterns.PoidStrategies.Add(new NativePoidPattern());
IEnumerable<Type> entities = new[] { typeof(Menu), typeof(Rights) };
orm.TablePerClass(entities);
orm.ManyToOne<Rights, Menu>();
Mapper mapper = new Mapper(orm);
mapper.Class<Menu>(cm =>
{
cm.Table("Tb_Sys_Menu");
});
mapper.Class<Rights>(cm =>
{
cm.Table("Tb_Sys_Rights");
cm.Id(u => u.Id, im => { im.Generator(Generators.Foreign<Rights>(u => u.Menu)); });
cm.ManyToOne(person => person.Menu, mtom =>
{
mtom.Unique(false);
mtom.NotNullable(true);
mtom.Cascade(Cascade.All);
});
});
-------------------------
It's very kind of you to help me!
2011-05-29
btlyeo
from China.Inner Mongolia
Hohhot