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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:18:06+00:00 2026-05-16T20:18:06+00:00

Ok, last edit, promise: With the following class: public partial class MembershipModule : BaseConnection<MembershipModule>

  • 0

Ok, last edit, promise:

With the following class:

public partial class MembershipModule : BaseConnection<MembershipModule>
{
    private const string AccessPrivilege = "Access";

    public bool Accessible()
    {
        return this.Privileges().Any(p => p.Name.Equals(AccessPrivilege));
    }

    public IQueryable<MembershipAction> Privileges()
    {
        var privileges = from p in LinqUtil.Context.MembershipModuleActions
                         where
                             p.MembershipModule.Id.Equals(this.Id) &&
                             p.MembershipRolePrivileges.Any(rp => rp.ModuleActionId.Equals(p.Id))
                         select p.MembershipAction;

        return privileges;
    }
}

Why does this work

    public static List<MembershipModule> Collection()
    {
        List<MembershipModule> collection = new List<MembershipModule>();

        if(!MembershipUser.Connected)
            return collection;

        foreach(MembershipModule m in LinqUtil.Context.MembershipModules)
        {
            if(m.Accessible())
                collection.Add(m);
        }

        return collection;
    }

While this doesn’t?

    public static List<MembershipModule> Collection()
    {
        if(!MembershipUser.Connected)
            return new List<MembershipModule>();

        return LinqUtil.Context.MembershipModules.Where(m => m.Accessible()).ToList();
    }
  • 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-16T20:18:06+00:00Added an answer on May 16, 2026 at 8:18 pm

    looks to me like you are trying to execute a linq to object operation and it is trying to convert it to a sql statement.

    Keep in mind: If this were to succede, I expect that the sql related to the folowing call would happen once per MembershipModule:

     return this.Privileges().Any(p => p.Name.Equals(AccessPrivilege)); 
    

    Have you tried skipping using the Accesible method, and hitting the Privileges collection directly? Something like this the code below. I have changed the return statement. This is the gist, may not be 100% correct:

    public static List<MembershipModule> Collection()      
    {      
        if(!MembershipUser.Connected)      
            return new List<MembershipModule>();      
    
        var mod = MembershipModule.SearchById(new Guid("b012d35f-6af1-47de-9e54-e5df957c07e1"));      
    
        var y = from p in LinqUtil.Context.MembershipModuleActions      
                where      
                    p.MembershipModule.Id.Equals(mod.Id) &&      
                    p.MembershipRolePrivileges.Any(rp => rp.ModuleActionId.Equals(p.Id))      
                select p.MembershipAction;      
    
        var u = y.Any(p => p.Name.Equals(AccessPrivilege));      
    
        return LinqUtil.Context.MembershipModules.Where(m => m.Privileges().Any(p => p.Name.Equals(AccessPrivilege)).ToList();  
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[ Note to the wise : jump to last EDIT ] I have a
Why does this not compile on VC 2005? bool isTrue(bool, bool) { return true;
I'm working on a subclass of threading.Thread which allows its methods to be called
could u help me out? I run this on cygwin as ./test.sh and I
Is there a way to keep the cusror location off-screen in Vim / gVim
I think I'm just cloudy on how debugging works on a real device -
I write shell scripts to do various things in OSX and Linux, but I
I've already asked 2 questions kind of related to this project, and i've reached
I want to run a function that has 2 different outcomes, but I want
I have a webpage that is a Search page. There are a few pre-defined

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.