Page 1 of 1

LinqConnect Professional Version 4.4.393 (12-Dec-2013) - Incorrect query for SQLite

Posted: Wed 25 Dec 2013 10:25
by AKRRKA
Using a navigational property in .Count() expression results in an invalid query (SQLite)
-----------------------------------------------------------------------------------------

When the following expression is executed:

q.Count(foo => foo.Bar.Baz == baz)

The corresponding SQL query is generated invalid:

Code: Select all

SELECT COUNT(*) AS C1
FROM Foos t1
WHERE (Baz = 'Lorem') AND datetime(t1.DT) > datetime('2013-12-25 13:00:00')
The query returns an error "no such column: Baz". Actually the "Baz" column doesn't belong to the "Foo" table, but it rather belongs to the "Bar" table. The correct query would be:

Code: Select all

SELECT COUNT(*) AS C1
FROM Foos t1
INNER JOIN Bars t2 ON t1.BarId = t2.BarId
WHERE (t2.Baz = 'Lorem') AND datetime(t1.DT) > datetime('2013-12-25 13:00:00')
Please see the sample project where the issue is apparent.
SqliteTest.7z (10.0 КБ) http://rghost.ru/51195684

Re: LinqConnect Professional Version 4.4.393 (12-Dec-2013) - Incorrect query for SQLite

Posted: Wed 25 Dec 2013 12:58
by MariiaI
Thank you for the report on this. We have reproduced this issue. We will investigate it and inform you about the results as soon as possible.

Re: LinqConnect Professional Version 4.4.393 (12-Dec-2013) - Incorrect query for SQLite

Posted: Sat 11 Jan 2014 14:38
by Shalex
As a workaround, please use

Code: Select all

q.Where(foo => foo.Bar.Baz == baz).Count()
instead of

Code: Select all

q.Count(foo => foo.Bar.Baz == baz)