Invalid SQL generated LinqConnect for Metro
Posted: Wed 20 Nov 2013 13:46
Hi,
This query works:
var q = from o in dbContext.OrderDetails
let c = o.Customer
let cc = c.CustomerCat
select new
{
cc.Description
};
var res = q.ToList();
and generates the SQL:
SELECT t3.Description AS Description
FROM "OrderDetail" t1
INNER JOIN "Customer" t2 ON t1.CustomerId = t2.Id
INNER JOIN "CustomerCat" t3 ON t2.CustomerCatId = t3.Id
However, this query fails:
var q = from o in dbContext.OrderDetails
select new
{
o.Customer.CustomerCat.Description
};
It generates the SQL:
SELECT t3.Description AS Description
FROM "OrderDetail" t1
INNER JOIN ("Customer" t2
INNER JOIN "CustomerCat" t3 ON t2.CustomerCatId = t3.Id) ON t1.CustomerId = t2.Id
which fails with
Devart.Data.SQLite.SQLiteException
HResult=-2146233088
Message=SQLite error
no such column: t3.Description
This query works:
var q = from o in dbContext.OrderDetails
let c = o.Customer
let cc = c.CustomerCat
select new
{
cc.Description
};
var res = q.ToList();
and generates the SQL:
SELECT t3.Description AS Description
FROM "OrderDetail" t1
INNER JOIN "Customer" t2 ON t1.CustomerId = t2.Id
INNER JOIN "CustomerCat" t3 ON t2.CustomerCatId = t3.Id
However, this query fails:
var q = from o in dbContext.OrderDetails
select new
{
o.Customer.CustomerCat.Description
};
It generates the SQL:
SELECT t3.Description AS Description
FROM "OrderDetail" t1
INNER JOIN ("Customer" t2
INNER JOIN "CustomerCat" t3 ON t2.CustomerCatId = t3.Id) ON t1.CustomerId = t2.Id
which fails with
Devart.Data.SQLite.SQLiteException
HResult=-2146233088
Message=SQLite error
no such column: t3.Description