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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:41:03+00:00 2026-05-16T23:41:03+00:00

am getting this error on this code (this is an MVC project into which

  • 0

am getting this error on this code (this is an MVC project into which I am trying to integrate Entity Framework):

        List<string> consultantSchoolList = new List<string>();

        // districts managed by consultant
        IQueryable<string> consultClients = rc.consultantDistrictsRepository.districtsForConsultant(userID);

        // schools managed by consultant
        if (consultClients != null)
        {
            consultantSchoolList = (from c in rc.clientsRepository.Clients
                                    where (consultClients.Contains(c.cdsCode.Substring(0, 7)))
                                    select c.cdsCode).ToList();
        }

on the “consultantSchoolList = ” line.

This is an MVC project and I am using a context object that is stored in the HttpContext.Current object. Each repository has a private variable that stores the context object, but each one should point to the same object in the HttpContext.Current Items collection. Would this be considered two different contexts even though they point to the same thing?

Stepping through the code in the debugger shows that the context objects for the two repositories, consultantDistrictsRepository and clientsRepository, do point to the same object in the HttpContext.Current object.

UPDATE Here’s how I define the context objects in each repository:

    private SchedulerContext context;

    public EFConsultantDistricts()
    {
        context = ContextHelper.GetContext();
    }

and GetContext is as follows:

    public static SchedulerContext GetContext()
    {
        if (!HttpContext.Current.Items.Contains("_db_context"))
        {
            HttpContext.Current.Items.Add("_db_context", new SchedulerContext());
        }
        return (SchedulerContext)HttpContext.Current.Items["_db_context"];
    }
  • 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-16T23:41:04+00:00Added an answer on May 16, 2026 at 11:41 pm

    I found the problem — I was caching the frequently-requested clients list in a Session variable in the Clients repository:

                if (HttpContext.Current.Session["clientList"] == null)
                {
                    HttpContext.Current.Session["clientList"] = from c in context.Clients
                                                                where (c.Year == fiscalYear)
                                                                select c;
                }
                return (IQueryable<Client>)HttpContext.Current.Session["clientList"];
    

    Since the Session object persists over requests, I guess it was using a previous context object. I thought the client list would be separated from the context object, but I guess not if I’m using IQueryable.

    I hate to hit the database every time for this, but I guess I have no choice … at least for the moment until I get everything straightened out.

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

Sidebar

Related Questions

I keep on getting this error error: expected specifier-qualifier-list for core data code im
I keep getting this error while trying to modify some tables. Here's my code:
Am getting this error for my code: Undefined symbols for architecture x86_64: _spendDollars, referenced
I'm getting this error message with the code below: class Money { public: Money(float
I am getting this error here is my code if(isset($_POST['submit'])) { $projTit=mysql_escape_string($_POST['projecttitle']); $projCat=mysql_escape_string($_POST['projectcategory']); $budget=intval(mysql_escape_string($_POST['budget']));
I am getting this error when I run the following code: #!/usr/bin/env ruby -rubygems
I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I am getting this error when I try to build for the device: Code
I keep getting this error whenever I call gethostbyname() in my C code. ==7983==
I don't understand why I'm getting this error. I used the same code previously

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.