IGNITE-4926: .NET: Fix LINQ join with subquery This closes #2166
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b16f725e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b16f725e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b16f725e Branch: refs/heads/ignite-2.1.2-exchange Commit: b16f725ecceddad3e97c98af7b0fe1e3ea256179 Parents: 9702194 Author: Sergey Stronchinskiy <[email protected]> Authored: Tue Jun 20 18:57:38 2017 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Tue Jun 20 18:57:38 2017 +0300 ---------------------------------------------------------------------- .../Cache/Query/CacheLinqTest.cs | 32 +++++++++++++++++--- .../Impl/CacheQueryExpressionVisitor.cs | 5 +++ 2 files changed, 33 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b16f725e/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs index 7874681..e46ae0b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs @@ -553,13 +553,37 @@ namespace Apache.Ignite.Core.Tests.Cache.Query var orgs = GetOrgCache().AsCacheQueryable().Where(x => x.Key > 10); - var res = persons.Join(orgs, - p => p.Value.OrganizationId, - o => o.Value.Id, (p, o) => p) + var qry1 = persons.Join(orgs, + p => p.Value.OrganizationId, + o => o.Value.Id, + (p, o) => p) .Where(x => x.Key >= 0) .ToList(); - Assert.AreEqual(PersonCount, res.Count); + Assert.AreEqual(PersonCount, qry1.Count); + + // With selector inline + var qry2 = persons + .Join(orgs.Select(orgEntry => orgEntry.Key), + e => e.Value.OrganizationId, + i => i, + (e, i) => e) + .ToList(); + + Assert.AreEqual(PersonCount, qry2.Count); + + // With selector from variable + var innerSequence = orgs + .Select(orgEntry => orgEntry.Key); + + var qry3 = persons + .Join(innerSequence, + e => e.Value.OrganizationId, + i => i, + (e, i) => e) + .ToList(); + + Assert.AreEqual(PersonCount, qry3.Count); } /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/b16f725e/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs index 396458e..d187f08 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs @@ -284,6 +284,11 @@ namespace Apache.Ignite.Linq.Impl ResultBuilder.AppendFormat("{0}.{1}", tableName, fieldname); } + else if (joinClause != null && joinClause.InnerSequence is SubQueryExpression) + { + var subQueryExpression = (SubQueryExpression) joinClause.InnerSequence; + base.Visit(subQueryExpression.QueryModel.SelectClause.Selector); + } else { // Count, sum, max, min expect a single field or *
