Entity Framework 5 on framework 4, contains and multiple outer joins with same table -
i having strange issue on application when deploying on windows 2008 r2 server.
given simple linq snippet:
return invoice in me.invoices loggedcustomerid.contains(invoice.contract.customerid) order invoice.date descending
the application works, in some cases (on customer server), generated t-sql strange:
select [extent1].[contractid] [contractid], ... [dbo].[invoice] [extent1] inner join [dbo].[contract] [extent2] on [extent1].[contractid] = [extent2].[contractid] left outer join [dbo].[contract] [extent3] on [extent1].[contractid] = [extent3].[contractid] [extent2].[customerid] = 482283 or [extent3].[customerid] in (498565,482282,498564,498566)
- table linked multiple times (?)
- the
in
statement broken multiple t-sql conditions instead of singlein
statement
obviously same package runs fine on system generating correct query without linking same table multiple times , creating single in
statement.
i using ef 5.0 compatibility against framework 4.0 (so assembly shows version 4.4). root cause of issue?
what wrong here?
it looks behavior related this? too many left outer joins in entity framework 4?
i've met analogous behavior in nhibernate, maybe find similarity.
we got simple parent
-> children
relation. point relation bidirectional parent referenced children , each of them has reference parent.
nhibernate supports lazy fetching switch off. produced interesting query once decided fetch whole aggregate, mean parent children.
something like:
select ... parent ... left join ... children ... left join parent
as nhibernate uses first level cache under hood, not able discover automatically parent instances equal cache of parent empty in time of query execution.
later during parsing of resulting database dataset, nhibernate found out parent entities have same primary identifier , returned 1 real instance.
Comments
Post a Comment