I m facing issue to access the bridge table to get the values using nHibernate and LINQ. I have 4 table, ROLES , MODULES , PERMISSIONS and the RoleModulePermission(bridge).
Roles contains ROLEID(pk) , ROLENAME
Modules contains MODULEID(pk) , MODULENAME
Permission contains PERMISSIONID , PERMISSIONTYPE
RoleModulePermission contains ROLEID , MODULEID and PERMISSIONID
I want to get the Modules n Permission applied to the ROLES on the basis of ROLEID.
Role Mapping
Table("tblRoles");
Id(role => role.RoleID).GeneratedBy.Identity();
Map(role => role.RoleName).Not.Nullable();
Map(role => role.IsActive).Not.Nullable();
Map(role => role.Description).Not.Nullable();
HasManyToMany(x => x.Users)
.Table("tblUserInRoles")
.ParentKeyColumn("RoleID")
.ChildKeyColumn("UserID")
.Not.LazyLoad();
HasManyToMany(x => x.Modules)
.Table("tblRolesPermission")
.ParentKeyColumn("RoleID")
.ChildKeyColumn("ModuleID")
.Not.LazyLoad();
HasManyToMany(x => x.Permissions)
.Table("tblRolesPermission")
.ParentKeyColumn("RoleID")
.ChildKeyColumn("PermissionID")
.Not.LazyLoad();
Module Mapping
Table("tblAppModules");
Id(mod => mod.ModuleID).GeneratedBy.Identity();
Map(mod => mod.ModuleName).Nullable();
Map(mod => mod.CreationDate).Nullable();
HasManyToMany(x => x.Roles)
.Table("tblRolesPermission")
.ParentKeyColumn("ModuleID")
.ChildKeyColumn("RoleID")
.Not.LazyLoad();
Permission Mapping
Table("tblPermission");
Id(p => p.PermissionID).GeneratedBy.Identity();
Map(p => p.PermissionType).Not.Nullable();
HasManyToMany(p => p.PermitRole)
.Table("tblRolesPermission")
.ParentKeyColumn("PermissionID")
.ChildKeyColumn("RoleID")
.Not.LazyLoad();
It seems that i did wrong in mapping ?
please do not assume 'AllowAccess' in tblRolesPermission How to achieve this ?
Thanks