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

EF Core 3.0 Broke PredicateBuilder #18333

Closed
davesmits opened this issue Oct 11, 2019 · 1 comment
Closed

EF Core 3.0 Broke PredicateBuilder #18333

davesmits opened this issue Oct 11, 2019 · 1 comment

Comments

@davesmits
Copy link

Queries that using Predicate Builder been working in .Net Core 2.2 are now with 3.0 broken
For example the query below

	    var x = 1;
	    var result = new [] { 2, 3, 4, 5 }
            var or = PredicateBuilder.False<Model>();

            foreach (var xx in result)
                or = PredicateBuilder.Or(or, x => x.Id == xx);

            var cases = await _context.RuleIndexes.Where(x => x.Id != x)
                .Where(or)
                .ToListAsync();

*ignore the used predicates; they dont make any sense but removed the real ones for simplicity as the problem is in the PredicateBuilder.Or

Expected result would be the queryies would still run. Now result in an exception

System.AggregateException: One or more errors occurred. (One or more errors occurred. (The LINQ expression 'Where(
source: Where(
source: DbSet,
predicate: (r) => r.CaseId != (Unhandled parameter: __caseId_0)),
predicate: (r) => False || Invoke(x => (((__xx_RuleId_1 == x.RuleId) AndAlso (__xx_Min_2 <= x.Value)) AndAlso (__xx_Max_3 >= x.Value)), r[RuleIndex])
)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync()

somewhat related to #15670 but it breaks existing code which is really painful

@smitpatel
Copy link
Contributor

Duplicate of #17791

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