Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3845910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:19:00+00:00 2026-05-19T16:19:00+00:00

How to assign the result of the Linq Query to a dictionary… public Dictionary<string,

  • 0

How to assign the result of the Linq Query to a dictionary…

 public Dictionary<string, Privilege> GetAllPermissionsByGroupId(string groupid)
    {

        string[] Roles = new string[] { "e8b08a45-9cb5-4ac9-8c6c-9dfe4ac23966$Moderator" };

        List<RolePrivilege> RoleList = new List<RolePrivilege>();
        List<Privilege> PrivilegeList = new List<Privilege>();

        Dictionary<string, RolePrivilege> Role = PrivilegeProxy.GetPrivilegesForRoles("744A2BE3-846E-4E4A-9796-DAF9C743E8FF", Roles);
        RoleList = Role.Values.ToList();


        Dictionary<string, Privilege> Privilege = PrivilegeProxy.GetPrivilegesbyModuleIds(new string[] { "Groups" });
        PrivilegeList = Privilege.Values.ToList();

        var identicalQuery = from roles in RoleList
                            join privileges in PrivilegeList on roles.PrivilegeName equals privileges.Name
                           select new { Roles = roles, Privileges = privileges };


        Dictionary<string, Privilege> Result=new Dictionary<string,Privilege>();
         Result=?


         return Result;

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:19:00+00:00Added an answer on May 19, 2026 at 4:19 pm

    Actually you code does not illustrate what you desire to put into dictionary. What should be key? String associated with RolePrivilege?

    Nevermind, I would recommend work with pairs instead of values in your dictionaries:

    var Roles = new string[] { "e8b08a45-9cb5-4ac9-8c6c-9dfe4ac23966$Moderator" };
    Dictionary<string, RolePrivilege> Role = PrivilegeProxy.GetPrivilegesForRoles("744A2BE3-846E-4E4A-9796-DAF9C743E8FF", Roles);
    Dictionary<string, Privilege> Privilege = PrivilegeProxy.GetPrivilegesbyModuleIds(new string[] { "Groups" });
    
    var identicalQuery = from roles in Role
                         join privileges in Privilege on roles.Value.PrivilegeName equals privileges.Value.Name
                         select new { Roles = roles, Privileges = privileges };
    
    Dictionary<string, Privilege> Result = identicalQuery.ToDictionary(_ => _.Roles.Key, _.Privileges.Value);
    

    EDITED

    Okay, let’s imagine contents of both dictionaries:

    • Role dic = [{“aaa”, RolePrivilege1}, {“bbb”, RolePrivilege2}, {“ccc”, RolePrivilege3}]
    • Privilege dic = [{“aaa”, Privilege5}, {“bbb”, Privilege6}, {“ddd”, Privilege7}]

    What do you expect as output?
    I suppose you want to get next sequense:

    • Result = [{“aaa”, Privilege5}, {“bbb”, Privilege6}]

    Correct? If yes, this request will help:

            var Result = Role
                .Join(Privilege,
                    outer => outer.Key,
                    inner => inner.Key,
                    (outer, inner) => new { Str = outer.Key, Privilege = inner.Value })
                .ToDictionary(_ => _.Str, _ => _.Privilege);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to assign a value from a query result to a session
i want to assign the linq result to a multidimensional array and the below
I've got a linq query that will return 1 result which will be an
I have a LINQ query such as: using(csv.......) { csv.Select(x => new Data() {
Can any one please help me, how to assign result of select query to
How to assign the result of a query to a variable in PL/pgSQL, the
I would like to add the result of a LINQ 2 SQL query to
I can't assign the result of query to variable (the program is written in
AIM : Convert a resultset to XML and assign the result to a variable
a short question: is it possible to assign the result of a calculation within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.