Skip to content
This repository was archived by the owner on Apr 5, 2019. It is now read-only.
This repository was archived by the owner on Apr 5, 2019. It is now read-only.

Bug with query plan caching #18

@HSchwichtenberg

Description

@HSchwichtenberg

Filters don't work correctly if I repeat the same exactly query within an App Domain.
a) If I first load all entities (step 1) and then apply filters (step 2), I still get all entities in step 2. SQL Server profiler proves, that the same SQL query is sent as in step 1.
b) However, if I omit step 1 and start with step 2, filters are applied correctly. But then in step 3 filters are applied as well, although they should not be active in this context instance. SQL Server profiler proves, that the same SQL query is sent as in step 2.

I assume there is a bug with in your code, that Entity Framework query plan caching is not handled properly. Using DisableFilter() does not solve this problem. If I use slightly different queries in the different steps, the filters work fine.

  var Ort = "abc";
   // Step 1
   using (var ctx1 = new FluggesellschaftContext())
   {
    var flugListe1 = ctx1.Fluege.Where(x => x.Abflugort.StartsWith(Ort)).ToList();
    foreach (var f in flugListe1)
    {
     PrintFlug(f);
    }
   }

   // Step 2
   using (var ctx2 = new FluggesellschaftContext())
   {
    ctx2.EnableFilter("NichtRaucherFluege");
    ctx2.EnableFilter("AuslastungHoch");
    ctx2.EnableFilter("Mandant").SetParameter("fluggesellschaft", FlugGesellschaften.WorldWideWings);

    var flugListe2 = ctx2.Fluege.Where(x => x.Abflugort.StartsWith(Ort)).ToList();
    foreach (var f in flugListe2)
    {
     PrintFlug(f);
    }
   }

   // Step 3
   using (var ctx3 = new FluggesellschaftContext())
   {
    var flugListe3 = ctx3.Fluege.Where(x => x.Abflugort.StartsWith(Ort)).ToList();
    foreach (var f in flugListe3)
    {
     PrintFlug(f);
    }
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions