How do I get a right outer join in L2E?
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.
开发者_StackOverflow中文版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 }
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 }
精彩评论