locked
Merge repsitories RRS feed

  • Question

  • User159714378 posted

    I developing enityframework code first approch application using repository.

    In this application based on logged user we getting roles. based on this roles we getting menu's for that logged user. one user can maintain multiple roles

    For this purpose i maintain 5 tables user, role, userroles, menu, menuroles. and we getting these table values in respective repositories

    user repository for user
    role repository for role
    userrole repository for userrole
    menu repository for menu
    menuroles repository for menuroles etc

    In menurole page we setting Add, Delete, Edit, View permissions

    in menu table containing id and menuname
    in role table containing id and rolename

    menurole containing menuId, roleid edit, add delete permissions etc

    newly create menu not coming in menurole table. now my requirement is i need to display newly created menu and same time already setted permissions in one page. i mean what will be repository query for this purpose

    Monday, March 7, 2016 8:45 AM

All replies

  • User-986267747 posted

    Hi actgmbh,

    actgmbh

    now my requirement is i need to display newly created menu and same time already setted permissions in one page. i mean what will be repository query for this purpose

    As your requirement, you would like to retrieve all of the related menurole for a specific menu, aren't you? if this is the case, you could add a navigate property (code as below) on the entity named menu. It will add a foreign key on the table named menurole, then you could get all of related menuroles via the navigate property.

    public partial class Menu
        {
            public Menu()
            {
                MenuRoles = new HashSet<MenuRole>();
    
            }
    
             public int Id { get; set; }
     
            public string MenuName { get; set; }
     
            public virtual ICollection<MenuRole> MenuRoles { get; set; }
    
    }
    

    For more information about navigation properties, please refer to the following link.

    https://msdn.microsoft.com/en-us/data/jj713564.aspx

    Best regards,

    Klein Zhang

    Tuesday, March 8, 2016 7:24 AM