6

Why does .NET Entity Framework produce SQL that uses a subquery and left outer join on a simple 1-to-1 relationship? I expected to see a simple join on the two tables. I'm using Devart Dotconnect for Oracle. Any ideas?

Below is the output I see courtesy of the EFTracingProvider:

SELECT
1 AS C1,
"Join1".USER_ID1 AS USER_ID,
...
FROM  "MY$NAMESPACE".MYTABLE1 "Extent1"
INNER JOIN  (...
    FROM  "MY$NAMESPACE".MYTABLE2 "Extent2"
    LEFT OUTER JOIN "MY$NAMESPACE".MYTABLE1 "Extent3" ON "Extent2".OTHER_ID = "Extent3".OTHER_ID ) 
    "Join1" ON "Extent1".OTHER_ID = "Join1".OTHER_ID1
WHERE "Extent1".USER_ID = :EntityKeyValue1
-- EntityKeyValue1 (dbtype=String, size=6, direction=Input) = "000000"
Taylor Leese
  • 51,004
  • 28
  • 112
  • 141

1 Answers1

0

In database theory, it is assumed that in a one-to-one relationship, A row on one side must be created before the corresponding row on the other side. If you didn't use an outer join, then you could never list the rows which had no match.

SMerrill8
  • 528
  • 4
  • 12