SCM

[#1010902] EF: SQL Builder fails with chained First() and including an entity collection

View Trackers | Bugs | Download .csv | Monitor

Date:
2010-09-23 11:18
Priority:
3
State:
Open
Submitted by:
Oliver Artelt (witte)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.10
Category:
Group:
Resolution:
None
Summary:
EF: SQL Builder fails with chained First() and including an entity collection

Detailed description
Hello,

the Query fails, because

var qry = ctx.countries.Include("cities").First(p => p.name1 == "Japan").cities.First(p => p.name1 == "Yokohama");

Please see the uploaded example project.
Many thanks.


Exception:

System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> Npgsql.NpgsqlException: ERROR: 42601: syntax error at or near "LEFT"
at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
at Npgsql.ForwardsOnlyDataReader.NextResult()
at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)
at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior cb)
at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__0[TResult](IEnumerable`1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.First[TSource](IQueryable`1 source, Expression`1 predicate)
at EFTest.Program.Main(String[] args) in C:\Dokumente und Einstellungen\oa\Desktop\EFTest\EFTest\Program.cs:line 25

SQL (catched by wireshark):

SELECT "Project1"."idcountry" AS "idcountry","Project1"."name1" AS "name1","Project1"."C1" AS "C1","Project1"."idcity" AS "idcity","Project1"."keycountry" AS "keycountry","Project1"."name11" AS "name11" FROM (SELECT "Extent1"."idcountry" AS "idcountry","Extent1"."name1" AS "name1","Extent2"."idcity" AS "idcity","Extent2"."keycountry" AS "keycountry","Extent2"."name1" AS "name11", CASE WHEN ("Extent2"."idcity" IS NULL ) THEN (CAST (NULL AS int4)) ELSE (1) END AS "C1" FROM "public"."countries" AS "Extent1" WHERE 'Japan'="Extent1"."name1" LIMIT 1 LEFT OUTER JOIN "public"."cities" AS "Extent2" ON "Extent1"."idcountry"="Extent2"."keycountry") AS "Project1" ORDER BY "Project1"."idcountry" ASC ,"Project1"."C1" ASC

Followup

No Followups Have Been Posted

Attached Files:

Attachments:
EFTest.rar

Changes:

Field Old Value Date By
File Added549: EFTest.rar2010-09-23 11:18witte
Powered By FusionForge