Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Query is not working in preview6 #16115

Closed
jose8789 opened this issue Jun 16, 2019 · 2 comments
Closed

Global Query is not working in preview6 #16115

jose8789 opened this issue Jun 16, 2019 · 2 comments

Comments

@jose8789
Copy link

jose8789 commented Jun 16, 2019

I have a simple repository with a method to retrieve all courses

return Context.Set<Course>().IgnoreQueryFilters()
                        //.Skip(offset).Take(limit)
                        .ToList();

and it gives the current error

Message: 
    System.ArgumentException : Expression of type 'Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalShapedQueryCompilingExpressionVisitor+QueryingEnumerable`1[Oculos.Gnaf.Courses.ReadModels.Models.Course]' cannot be used for parameter of type 'System.Linq.IQueryable`1[Oculos.Gnaf.Courses.ReadModels.Models.Course]' of method 'System.Linq.IQueryable`1[Oculos.Gnaf.Courses.ReadModels.Models.Course] IgnoreQueryFilters[Course](System.Linq.IQueryable`1[Oculos.Gnaf.Courses.ReadModels.Models.Course])'
    Parameter name: arg0
  Stack Trace: 
    at ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
    at Expression.Call(MethodInfo method, Expression arg0)
    at MethodCallExpression1.Rewrite(Expression instance, IReadOnlyList`1 args)
    at ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
    at MethodCallExpression.Accept(ExpressionVisitor visitor)
    at ExpressionVisitor.Visit(Expression node)
    at QueryCompilationContext2.CreateQueryExecutor[TResult](Expression query)
    at Database.CompileQuery2[TResult](Expression query, Boolean async)
    at QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
    at <>c__DisplayClass9_0`1.<Execute>b__0()
    at CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
    at CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
    at QueryCompiler.Execute[TResult](Expression query)
    at EntityQueryProvider.Execute[TResult](Expression expression)
    at EntityQueryable`1.GetEnumerator()
    at List`1.ctor(IEnumerable`1 collection)
    at Enumerable.ToList[TSource](IEnumerable`1 source)

Steps to reproduce

public class Course 
    {
        public string Abbreviation { get; set; }
        public int Id { get; set; }
        public string Name { get; set; }
        public bool IsDeleted { get; set; }
    }

in dbcontex

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBmodelBuilder.Entity<Course>().HasQueryFilter(x => !x.IsDeleted);
        }

in repository:

return Context.Set().IgnoreQueryFilters()
//.Skip(offset).Take(limit)
.ToList();

Further technical details

EF Core version: 3.0.0-preview6.19304.10
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: (e.g. Visual Studio 2019 16.2)

@ajcvickers
Copy link
Contributor

@jose8789 First, many thanks for trying preview 6. We really appreciate people trying the previews and filing issues on what they find.

If you haven't seen it already, there is some good information in the preview announcement post about the changes that are happening to LINQ queries for EF Core 3.0. Preview 6 is the first release containing these changes, which means we are both expecting things to be broken, but at the same time very grateful for everyone who tries the release and generated feedback.

Note from triage: In this case, query filters is something that is not working in this preview. @smitpatel Do we have/need a specific issue tracking this?

@smitpatel
Copy link
Contributor

Duplicate of #15264

@smitpatel smitpatel marked this as a duplicate of #15264 Jun 17, 2019
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants