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

  • Home
  • SEARCH
  • 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 7458139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:24:37+00:00 2026-05-29T13:24:37+00:00

I have an issue here a bit complex than I’m trying to resolve since

  • 0

I have an issue here a bit complex than I’m trying to resolve since some days ago. I’m using the PetaPoco ORM and didn’t found any other way to do a complex query like this:

   var data = new List<string[]>();
   var db = new Database(connectionString);
   var memberCapabilities = db.Fetch<dynamic>(Sql.Builder
       .Select(@"c.column_name
           ,CASE WHEN c.is_only_view = 1
               THEN c.is_only_view
               ELSE mc.is_only_view end as is_only_view")
       .From("capabilities c")
       .Append("JOIN members_capabilities mc ON c.capability_id = mc.capability_id")
       .Where("mc.member_id = @0", memberID)
       .Where("c.table_id = @0", tableID));

   var roleCapabilities = db.Fetch<dynamic>(Sql.Builder
       .Select(@"c.column_name
           ,CASE WHEN c.is_only_view = 1
               THEN c.is_only_view
               ELSE rc.is_only_view end as is_only_view")
       .From("capabilities c")
       .Append("JOIN roles_capabilities rc ON c.capability_id = rc.capability_id")
       .Append("JOIN members_roles mr ON rc.role_id = mr.role_id")
       .Where("mr.member_id = @0", memberID)
       .Where("c.table_id = @0", tableID));

I’m trying to get the user capabilities, but my system have actually to ways to assign an user a capability, or direct to that user or attaching the user to a role. I wanted to get this merged list using a stored procedure but I needed cursors and I thought maybe should be easier and faster doing this on the web application. So I get that two dynamics and the members capabilities have priority to the roles capabilities, so I need to check if that using loops. And I did like this:

   for (int i = 0; i < roleCapabilities.Count; i++)
   {
       bool added = false;
       for (int j = 0; j < memberCapabilities.Count; j++)
           if (roleCapabilities[i].column_name == memberCapabilities[j].column_name)
           {
               data.Add(new string[2] { memberCapabilities[j].column_name, Convert.ToString(memberCapabilities[j].is_only_view) });
               added = true;
               break;
           }
       if (!added)
           data.Add(new string[2] { roleCapabilities[i].column_name, Convert.ToString(roleCapabilities[i].is_only_view) });
        }

So now the plan is delete the duplicate entries. I have try using the following methods with no results:

  data = data.Distinct();

Any help? Thanks

  • 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-29T13:24:38+00:00Added an answer on May 29, 2026 at 1:24 pm

    If I understand your question correctly you want to get a distinct set of arrays of strings, so if the same array exists twice, you only want one of them? The following code will return arrays one and three while two is removed as it is the same as one.

    var one = new[] {"One", "Two"};
    var two = new[] {"One", "Two"};
    var three = new[] {"One", "Three"};
    
    List<string[]> list = new List<string[]>(){one, two, three};
    
    
    var i = list.Select(l => new {Key = String.Join("|", l), Values = l})
        .GroupBy(l => l.Key)
        .Select(l => l.First().Values)
        .ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello fellow java developers. I'm having a bit of an issue here. I have
I have an issue going on here. I am using PHP to get values
I have been trying to find this issue here, but no topic seems to
I have a bit of a strange issue here. I created a custom control
I'm having a strange issue here, i have this bit of code: <?php if
I have a bit of an issue here. As Im new to jQuery this
I have a bit of a complex issue with a CSS background. Check out
I have a bit complex to explain issue that I have ran into: I
I'd like to have some help on an issue I face. I'm using serialization
I have a bit of an issue here. I have a Python script which

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.