Fields mapped on relations deeper than 2 levels.

Posts   
 
    
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 01-Sep-2008 18:22:47   

Given the attached database model for the permissions (rolebased)

I try to figure out the quickest way to get the permissioncollection, per UserEntity. The most i get is RoleCollectionViaRoleUser, but what i would like to have is User.PermissionCollectionViaRolePermissionViaRoleViaRoleUser.

There's gonna be a funcion in my Roleprovider that will query the roles a user is in quite often, so i need this to be a resource-efficient method.

Anyone who can give me some pointers?

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Sep-2008 06:04:40   

I'm afraid there's no such direct approach. You have to write the bucket yourself (add relations and appropriate filter). You could do that in some utility function so you don't have to write the full graph every time you need it.

(Edit) You also can write a custom property at UserEntity that returns such Permission collection.

public UserEntity
{
...

     public EntityCollection<PermissionCollection>
     {
         // return the desire collection
     }
}

Please let us know if you need further help on this.

David Elizondo | LLBLGen Support Team
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 16-Sep-2008 13:08:22   

Daelmo, thanks! I took your advice on this one, and i'm using a partial class with custom properties now to do this.