We are using a registered version of DotConnect for PostgreSQL (7.3.274.6) with Entity Framework 6 and are testing some basic query using LINQ and Expression Trees.
Writing a small program like:
using (DBAuraContext context = new DBAuraContext(utente.Utente.ORMConfiguration))
{
IQueryable<Assortimenti> query = context.Assortimenti;
DateTime val = new DateTime(2010, 1, 1, 0, 0, 0);
query = query.Where(r => r.DataOraAggiornamento.Value.CompareTo(val) >= 0);
query = query.OrderBy(r => r.CodiceAssortimento);
string sql = query.ToString();
Console.WriteLine(sql);
}
we see this generated sql statement:
SELECT
Project1.IDAssortimenti,
Project1.CodiceAssortimento,
Project1.Descrizione,
Project1.Tipo,
Project1.DataOraAggiornamento,
Project1.RowVersion
FROM ( SELECT
Extent1.IDAssortimenti,
Extent1.CodiceAssortimento,
Extent1.Descrizione,
Extent1.Tipo,
Extent1.DataOraAggiornamento,
Extent1.RowVersion
FROM Assortimenti AS Extent1
WHERE Extent1.DataOraAggiornamento >= :p__linq__0
) AS Project1
ORDER BY Project1.CodiceAssortimento ASC
while we would expect something like:
SELECT
Extent1.IDAssortimenti,
Extent1.CodiceAssortimento,
Extent1.Descrizione,
Extent1.Tipo,
Extent1.DataOraAggiornamento,
Extent1.RowVersion
FROM Assortimenti AS Extent1
WHERE Extent1.DataOraAggiornamento >= :p__linq__0
ORDER BY Extent1.CodiceAssortimento ASC
Is this behaviour normal ?
Strange sql generated from EF query
Re: Strange sql generated from EF query
Thank you for your report. We will investigate the issue with extra subselect when using ordering and notify you about the result.
-
- Posts: 7
- Joined: Fri 19 Dec 2014 07:42
Re: Strange sql generated from EF query
Any news about this issue ?
Re: Strange sql generated from EF query
The investigation is in progress. As soon as we have any results, we will let you know.
-
- Posts: 7
- Joined: Fri 19 Dec 2014 07:42
Re: Strange sql generated from EF query
OK, Thank you