-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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.1 Urgent Issue:- ToQuery Method with Left Outer Join Causes an Error although it was working Properly with Previous Version #19708
Comments
Dears, any help ? |
@ahmedtolba1984 If you need urgent help, there are paid support options |
@ahmedtolba1984 I can reproduce what you are seeing, but I'm not sure why it is failing. @maumar @roji Could you guys take a look? We might need @smitpatel to take a look when he is back. |
GroupJoin method translation is not supported. Problem is that for regular query we run pre-processing step that flattens SelectMany-GroupJoin-DefaultIfEmpty into LeftJoin, which we can translate. When using view however, at the time of flattening the query doesn't have it's Defining query extracted, so the SM-GJ-DIE pattern is not available for flattening. We only peek into defining query during nav rewrite |
Fix is to run missing pre-processing steps after the defining query has been extracted, but before the extracted query is put thru nav rewrite itself. |
related to #17270 |
@maumar Thanks for feedback but when this problem will be solved or Is there any workaround for such issue? |
@ahmedtolba1984 no good workaround, at least if you want to use ToQuery. If the issue is very urgent for you, the best approach is probably to apply the fix yourself: add the following line of code: processedDefiningQueryBody = new GroupJoinFlatteningExpressionVisitor().Visit(processedDefiningQueryBody); |
@maumar |
@ahmedtolba1984 unfortunately this issue affects all providers |
@ahmedtolba1984 actually, workaround for your specific case could be to write a query already it its LeftJoin form: Expression<Func<IQueryable<CustomerView>>> query = () =>
QueryableExtensions.LeftJoin(Customers, CustomerMemberships, c => c.Id, cm => cm.CustomerId, (customer, customerMembership) => new CustomerView
{
Id = customer.Id,
Name = customer.Name,
CustomerMembershipId = customerMembership != null ? customerMembership.Id : default(int?),
CustomerMembershipName = customerMembership != null ? customerMembership.Name : ""
}); |
ToQuery method may be removed in #17270. |
Introduces QueryableMethodNormalizingExpressionVisitor which - Extract query metadata methods - Convert from enumerable to queryable - Convert List.Contains to queryable Contains - Flatten GroupJoin-SelectMany Nav expansion now calls this method on query filter/ defining query Resolves #19708
Introduces QueryableMethodNormalizingExpressionVisitor which - Extract query metadata methods - Convert from enumerable to queryable - Convert List.Contains to queryable Contains - Flatten GroupJoin-SelectMany Nav expansion now calls this method on query filter/ defining query Resolves #19708 Part of #18923
Introduces QueryableMethodNormalizingExpressionVisitor which - Extract query metadata methods - Convert from enumerable to queryable - Convert List.Contains to queryable Contains - Flatten GroupJoin-SelectMany Nav expansion now calls this method on query filter/ defining query Resolves #19708 Part of #18923
I am facing an issue after converting the project from .Net core 2.1 to 3.1. I have following linq code: var query = _context.FileDescriptor.Where(x => x.ClientId == clientId); Getting the below error while executing: |
@prashantaggarwal1990 - As the milestone indicates this issue is fixed in 5.0 release and it is not supposed to work in 3.1. |
Any workaround for this?
…________________________________
From: Smit Patel ***@***.***>
Sent: Thursday, April 29, 2021 8:18:28 PM
To: dotnet/efcore ***@***.***>
Cc: prashantaggarwal1990 ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/efcore] EF Core 3.1 Urgent Issue:- ToQuery Method with Left Outer Join Causes an Error although it was working Properly with Previous Version (#19708)
@prashantaggarwal1990<https://github.com/prashantaggarwal1990> - As the milestone indicates this issue is fixed in 5.0 release and it is not supposed to work in 3.1.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#19708 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AD2W3EORCNENAJPL6TE533DTLFWTZANCNFSM4KLSPOZA>.
|
There are few work-around mentioned in the comments above. Apart from that either upgrade to 5.0 or avoid using ToQuery. |
In EF Core 2.1, I was able to test SQL View with InMemory Provider using a custom ToQuery() method, like below:-
but after i upgrade to EF Core 3.1, I got an exception "System.InvalidOperationException : Processing of the LINQ expression" although my ToQuery method code works properly outside the method.
Kindly, check the stack trace and working sample that produce the issue
The text was updated successfully, but these errors were encountered: