You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some queries result in generated SQL containing projections with an SQL parameter as constant in column selection. E.g.
SELECT @p__linq__2 AS "p__linq__2" FROM Table1
which results in a "Data type unknown" error.
Containing an explicit cast. the statement is executable:
SELECT CAST(@p__linq__2 AS TIMESTAMP) AS "p__linq__2" FROM Table1
I can reproduce it by using a filter with a captured parameter and a grouping followed by a projection selecting both a group aggregate and the group itself:
DateTime dateTime = DateTime.Now;
var query = this.objectContext.TABLE1
.Select(entity => new { entity.SomeDateTime, entity.SomeValue1, entity.SomeValue2 })
.Where(entity => entity.SomeDateTime>dateTime)
.GroupBy(entity => entity.SomeValue1)
.Select(group => new
{
Sum = group.Sum(entity => entity.SomeValue2),
Values = group
})
.ToList();
The text was updated successfully, but these errors were encountered:
Your query results into:
SELECT
"Project2"."C2" AS "C1",
"Project2"."C1" AS "C2",
"Project2"."SOMEVALUE1" AS "SOMEVALUE1",
"Project2"."C3" AS "C3",
"Project2"."SOMEDATETIME" AS "SOMEDATETIME",
"Project2"."SOMEVALUE11" AS "SOMEVALUE11",
"Project2"."SOMEVALUE2" AS "SOMEVALUE2"
FROM ( SELECT
"GroupBy1"."A1" AS "C1",
"GroupBy1"."K1" AS "SOMEVALUE1",
1 AS "C2",
"Project1"."SOMEDATETIME" AS "SOMEDATETIME",
"Project1"."SOMEVALUE1" AS "SOMEVALUE11",
"Project1"."SOMEVALUE2" AS "SOMEVALUE2",
"Project1"."C1" AS "C3"
FROM (SELECT
"Extent1"."SOMEVALUE1" AS "K1",
SUM("Extent1"."SOMEVALUE2") AS "A1"
FROM "TABLE1" AS "Extent1"
WHERE "Extent1"."SOMEDATETIME" > @p__linq__0
GROUP BY "Extent1"."SOMEVALUE1" ) AS "GroupBy1"
LEFT OUTER JOIN (SELECT
"Extent2"."SOMEDATETIME" AS "SOMEDATETIME",
"Extent2"."SOMEVALUE1" AS "SOMEVALUE1",
"Extent2"."SOMEVALUE2" AS "SOMEVALUE2",
1 AS "C1"
FROM "TABLE1" AS "Extent2" ) AS "Project1" ON ("Project1"."SOMEDATETIME" > @p__linq__0) AND (("GroupBy1"."K1" = "Project1"."SOMEVALUE1") OR (("GroupBy1"."K1" IS NULL) AND ("Project1"."SOMEVALUE1" IS NULL)))
) AS "Project2"
ORDER BY "Project2"."SOMEVALUE1" ASC, "Project2"."C3" ASC
and there's no direct selection of param. Probably your model is specific hence provide script to create the table (and updated query, if required).
Submitted by: Daniel Richter (danielrichter)
Some queries result in generated SQL containing projections with an SQL parameter as constant in column selection. E.g.
SELECT @p__linq__2 AS "p__linq__2" FROM Table1
which results in a "Data type unknown" error.
Containing an explicit cast. the statement is executable:
SELECT CAST(@p__linq__2 AS TIMESTAMP) AS "p__linq__2" FROM Table1
I can reproduce it by using a filter with a captured parameter and a grouping followed by a projection selecting both a group aggregate and the group itself:
DateTime dateTime = DateTime.Now;
var query = this.objectContext.TABLE1
.Select(entity => new { entity.SomeDateTime, entity.SomeValue1, entity.SomeValue2 })
.Where(entity => entity.SomeDateTime>dateTime)
.GroupBy(entity => entity.SomeValue1)
.Select(group => new
{
Sum = group.Sum(entity => entity.SomeValue2),
Values = group
})
.ToList();
The text was updated successfully, but these errors were encountered: