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 6785695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:09:30+00:00 2026-05-26T17:09:30+00:00

Below method selects admin rights and returns bool from a cached DataTable, would it

  • 0

Below method selects admin rights and returns bool from a cached DataTable, would it perform better with Linq?

You might ask why don’t you test it. Well,due to lack of knowledge i can’t write it in Linq

 DataRow[] result = PrivilegeMap.Select("privilegeActionId=" + (int)actionId);
            bool moderatorHasIt = Convert.ToBoolean(result[0]["moderatorHasIt"]);
            bool adminHasIt = Convert.ToBoolean(result[0]["adminHasIt"]);                                        
            if (myRole == User.Role.Admin)
            {
                return Convert.ToBoolean(adminHasIt);
            }
            if (myRole == User.Role.Moderator)
            {
                return Convert.ToBoolean(moderatorHasIt);
            }
            else
            {
                return false;
            }
  • 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-26T17:09:30+00:00Added an answer on May 26, 2026 at 5:09 pm

    It probably would be faster using LINQ because the datatable wouldn’t have to parse your query string, but you’ll get the greatest advantage by changing the data representation to avoid querying against a datatable in the first place.

    Create an IDictionary<int, bool> that represents the privileges you’re interested in, keyed by actionId. Then when you need to do a lookup, you can just return dict[actionId.

    Regardless, I suspect this is probably a case of Premature Optimization: have you tested your program and found that this piece of code represents a significant portion of your processing time?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to fetch a method's comments,take below method for example: /** * Returns
I have a search method below using linq, my search citeria is based on
How can I select the good method (I have in the example below show
I have the below method which is meant to append information to a file
I'm using the below method to reply to mails coming in to a business
The method below called UserCanAccessThisPage is based on the following logic: each user and
In the method below titleForHeaderInSection , for some reason the NSLog prints out the
I know the method below isn't meant to work with any Entity, and its
See the four lines in the Go() method below: delegate void Action<T>(T arg); delegate
I Send Iqueryable to a function that is below void Method<T>(ref IQueryable<T> qu) {

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.