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

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
AKRRKA
Posts: 198
Joined: Thu 26 Jan 2012 15:07
Location: Russia
Contact:

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

Post by AKRRKA » Wed 25 Dec 2013 10:25

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

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

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

Post by MariiaI » Wed 25 Dec 2013 12:58

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Sat 11 Jan 2014 14:38

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)

Post Reply