-
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
I can't add a defining query that uses a left join #19845
Comments
ChannelSix
changed the title
I can't a defining query that uses a left join
I can't add a defining query that uses a left join
Feb 8, 2020
@maumar to take a look. |
dupe of #19708 |
@ChannelSix you can use QueryableExtensions.LeftJoin method directly as a workaround: modelBuilder.Entity<ParentChild>()
.HasNoKey()
.ToQuery(() =>
Set<Parent>().LeftJoin(Set<Child>(), k => k.Id, k => k.ParentId, (p, cLeft) => new ParentChild
{
ParentId = p.Id,
ParentName = p.Name,
ChildId = cLeft == null ? (int?)null : cLeft.Id,
ChildName = cLeft == null ? null : cLeft.Name
})); QueryableExtensions is defined in |
Thanks for looking at this and the suggestion. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I create a defining query that uses a left join in EF Core v3.1.1 I get the exception below when attempting to query the defining query. Note that I can't use navigation properties on my actual models.
If I run the exact same expression through a normal query it runs fine.
Steps to reproduce
Exception:
System.InvalidOperationException: 'Processing of the LINQ expression 'DbSet
.GroupJoin(
outer: DbSet,
inner: p => p.Id,
outerKeySelector: c => c.ParentId,
innerKeySelector: (p, outer) => new {
p = p,
outer = outer
})' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.'
Further technical details
EF Core version: 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework:. NET Core 3.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.4.4
The text was updated successfully, but these errors were encountered: