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 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

I am working with an edit user view that includes First name, Last Name,
Last year I developed a data access service for our project using Entity Framework
I have the following string and regex: var string = Dear [to name], [your
I want emacs to add last edit location to the mark ring, so I
In a Django UserProfile model, I am trying to do the following: class UserProfile(models.Model):
I'm using ctrl + q very often to get to the last edit location.
EDIT: LAST UPDATE : So, we've tested some more. I used the facebook developers
IN THE END OF THE QUESTION MY LAST EDIT Hi all, I have to
private List<T> newList; public List<T> NewList { get{return newList;} set{newList = value;} } I
[ Note to the wise : jump to last EDIT ] I have a

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.