Description
Using Join with subquery works when subquery does not contain Select clause:
var persons = GetPersonCache().AsCacheQueryable().Where(x => x.Key >= 0); 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) .Where(x => x.Key >= 0) .ToList();
And fails when subquery is using Select:
var res = persons .Join( orgs.Where(orgEntry => orgEntry.Value.Name == "Org_1") .Select(orgEntry => orgEntry.Key), e => e.Value.OrganizationId, i => i, (e, i) => e) .ToList();
Exception:
Failed to parse SQL query: select _T0._key, _T0._val from "".Person as _T0 inner join (select _T1._key from "".Organization as _T1 where (_T1._key > ?) and (_T1.Name = ?) ) as _T2 on (_T2._key, _T2._val = _T0.OrganizationId) where (_T0._key >= ?) Caused by: org.h2.jdbc.JdbcSQLException: Column "_T2._VAL" not found;
This can be reproduced in CacheLinqTest.TestSubqueryJoin by adding next:
var foo = persons .Join( orgs.Where(orgEntry => orgEntry.Value.Name == "Org_1") .Select(orgEntry => orgEntry.Key), e => e.Value.OrganizationId, i => i, (e, i) => e) .ToArray();
or
var foo = orgs .Where(orgEntry => orgEntry.Value.Name == "Org_1") .Select(orgEntry => orgEntry.Key); var bar = persons .Join(foo, e => e.Value.OrganizationId, i => i, (e, i) => e) .ToArray();
Attachments
Issue Links
- links to