5
的字典我有一個分貝以下表格:功能NHibernate:映射列表
- 角色:[ID,姓名,...]
- 權限:[ID,姓名,... ]
- MetaDataDefinitions:[ID,姓名,...]
- RolePermissions:[ID,角色ID,PermissionId,MetaDataDefinitionId]
POCO類:
class Role {
public Role() {
MetaDataPermissions = new Dictionary<MetaDataDefinition, Permission>() ;
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IDictionary<MetaDataDefinition, Permission> MetaDataPermissions { get; set; }
}
class Permission {
public Permission() {
MetaDataRoles = new Dictionary<MetaDataDefinition, Role>() ;
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IDictionary<Role, MetaData> RolesMetaData { get; set; }
}
class MetaData {
public MetaData() {
RolePermissions = new Dictionary<Role, Permission>() ;
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IDictionary<Role, Permission> RolePermissions { get; set; }
}
流利的映射:
class RoleMap : ClassMap<Role> {
public RoleMap() {
[...]
HasManyToMany(x => x.MetaDataPermissions)
.Table("RolePermissions")
.AsEntityMap("MetaDataDefinitionId", "PermissionId")
.KeyColumn("RoleId") ;
[...]
}
}
class PermissionMap : ClassMap<Permission> {
public PermissionMap() {
[...]
HasManyToMany(x => x.RolesMetaData)
.Table("RolePermissions")
.AsEntityMap("RoleId", "MetaDataDefinitionId")
.KeyColumn("PermissionId") ;
[...]
}
}
class MetaDataMap : ClassMap<MetaData> {
public MetaDataMap() {
[...]
HasManyToMany(x => x.RolePermissions)
.Table("RolePermissions")
.AsEntityMap("RoleId", "PermissionId")
.KeyColumn("MetaDataDefinitionId") ;
[...]
}
}
但在POCO類,我需要這樣的:
public virtual IDictionary<Role, IList<MetaData>> RolesMetaData { get; set; }
怎麼這麼字典應該在映射表示?