views:

32

answers:

1

I have two tables that I set up through the VS Entity Data Model Diagram tool. I'm trying to do a right outer join and it doesn't return results from the 2nd table.

I have set up a 0..1 to MANY relationship from the diagram tool.

When I run a Linq-To-Entities query, it still defaults to an INNER JOIN. From my understanding of entities, if I set up the relationship using VS, when I join the tables, it should automagically figure out the join syntax based on the relationship I supply. It doesn't seem to be doing that.

I am using EF v1 (not Linq-to-Sql).

Query I'm running:

from s in SomeTable 
join t in SomeOtherTable on s.ID equals t.ID
select new { s.MyFieldName, t.MyOtherFieldName }
+1  A: 

DefaultIfEmpty() will help in Entity Framework 4:

from s in SomeTable 
join t in SomeOtherTable on s.ID equals t.ID into myTemps
from temp in myTemps.DefaultIfEmpty()
select new { s.MyFieldName, temp.MyOtherFieldName }
p.campbell
According to the documentation I've seen DefaultIfEmpty is only supported by L2S.
Dan
@Dan: indeed... my sample and answer was developed using EF4. Sorry, I can see now that you specified EF1. This answer won't be answering your question directly, but hopefully helpful to someone else in the future using EF4+.
p.campbell