From bcad1cf09e8cc34a0668189f9518849943761258 Mon Sep 17 00:00:00 2001 From: VAN HECKE Michiel Date: Thu, 23 Aug 2018 12:35:29 +0200 Subject: [PATCH] Include Expression could not handle extra join --- .../Query/RelationalQueryModelVisitor.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/EFCore.Relational/Query/RelationalQueryModelVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryModelVisitor.cs index 96a684652fa..4ea064f917a 100644 --- a/src/EFCore.Relational/Query/RelationalQueryModelVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryModelVisitor.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -1614,12 +1614,19 @@ var projection ? innerSelectExpression.Projection : Enumerable.Empty(); - var joinExpression - = outerSelectExpression.AddInnerJoin( - innerSelectExpression.Tables.Single(), + var joinExpression = outerSelectExpression.AddInnerJoin( + innerSelectExpression.Tables.First(), projection, innerSelectExpression.Predicate); + if (innerSelectExpression.Tables.Count > 1) + { + foreach (var otherTableExpression in innerSelectExpression.Tables.Skip(1)) + { + outerSelectExpression.AddTable(otherTableExpression); + } + } + joinExpression.Predicate = predicate; joinExpression.QuerySource = joinClause;