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

No server-side handling of Contains (LIKE) on optional relationships #6473

Closed
kierenj opened this issue Sep 4, 2016 · 3 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@kierenj
Copy link

kierenj commented Sep 4, 2016

Steps to reproduce

Complete repro project (uses mssqllocaldb):

https://github.com/RedRiverSoftware/ef-repros/tree/no-server-like-on-optional-relationship

(git clone, dotnet restore, ef database update, dotnet run)

By default RelationalEventId.QueryClientEvaluationWarning is set to throw. Remove line 13 of DemoContext.cs and it will instead log the details to the console.

The issue

I have a main entity and an optional child entity. When I try to filter with string.Contains on a property of the child entity (from the main entity), EF advises that it cannot process the query on the server.

Expected behaviour - something along the lines of using an INNER JOIN and LIKE when it's a single criterion, or an OUTER JOIN with LIKE or IS NULL test if there are further alternative filter criteria (i.e. ORed together).

Exception message: System.InvalidOperationException: Warning as error exception for warning 'RelationalEventId.QueryClientEvaluationWarning': The LINQ expression 'DefaultIfEmpty()' could not be translated and will be evaluated locally. To suppress this Exception use the DbContextOptionsBuilder.ConfigureWarnings API. ConfigureWarnings can be used when overriding the
 DbContext.OnConfiguring method or using AddDbContext on the application service provider.
Stack trace:

   at Microsoft.EntityFrameworkCore.Infrastructure.SensitiveDataLogger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](L
ogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)                                    
   at Microsoft.EntityFrameworkCore.Storage.RelationalLoggerExtensions.LogWarning(ILogger logger, RelationalEventId eventId
, Func`1 formatter)                                                                                                        
   at Remotion.Linq.QueryModelVisitorBase.VisitResultOperators(ObservableCollection`1 resultOperators, QueryModel queryMode
l)                                                                                                                         
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)                   
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)               
   at Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryModelVisitor.VisitQueryModel(QueryModel queryModel)       
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitSubQuery(SubQu
eryExpression expression)                                                                                                  
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)                  
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.ReplaceClauseReferences(Expression expression, IQuerySour
ce querySource, Boolean inProjection)                                                                                      
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CompileAdditionalFromClauseExpression(AdditionalFromC
lause additionalFromClause, QueryModel queryModel)                                                                         
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitAdditionalFromClause(AdditionalFromClause fromClause
, QueryModel queryModel, Int32 index)                                                                                      
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitAdditionalFromClause(AdditionalFromClause fromCl
ause, QueryModel queryModel, Int32 index)                                                                                  
   at Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)      
   at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)                                           
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)                   
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)               
   at Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryModelVisitor.VisitQueryModel(QueryModel queryModel)       
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)

Further technical details

EF Core version: 1.0.0
Operating system: Windows 10
Visual Studio version: n/a commandline

@divega
Copy link
Contributor

divega commented Sep 7, 2016

@anpete please confirm that this is a dupe of the general LEFT OUTER JOIN issue.

@divega divega added this to the 1.1.0 milestone Sep 7, 2016
@kierenj
Copy link
Author

kierenj commented Sep 17, 2016

@divega / @anpete - I'm getting many, many queries giving warnings around DefaultIfEmpty not being translatable. Would that potentially be this LEFT OUTER JOIN issue you refer to @divega? If so, might you have a link to that issue tracking that please? I'm on the nightlies from a few days ago but still getting the issues here. Thank you!

@anpete
Copy link
Contributor

anpete commented Sep 17, 2016

#4588

@maumar maumar modified the milestones: 1.1.0, 1.1.0-preview1 Oct 5, 2016
anpete added a commit that referenced this issue Oct 11, 2016
…onal relationships

- DefaultIfEmpty was indeed being lifted, but had to correct a small bug in nav. rewrite.
@anpete anpete closed this as completed in 51a805e Oct 11, 2016
@rowanmiller rowanmiller added type-bug closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed type-investigation labels Oct 12, 2016
@rowanmiller rowanmiller modified the milestones: 1.1.0-preview1, 1.1.0 Oct 12, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

6 participants