I'm creating a dynamic view to join two SQL Views which are mapped as entities.
I create two EntityFields, one for the key in the first view one for the key to match in the second view. I want all the rows from the first view and only the matches from the second view; a left join.
EntityField leftField = (EntityField)EntityFieldFactory.Create(leftViewName,leftFieldname);
EntityField rightField = (EntityField)EntityFieldFactory.Create(rightViewName,rightFieldname);
Then I create the relationship and add it to the relationship collection
EntityRelation r = new EntityRelation(leftField,rightField,RelationType.ManyToMany);
relations.Add(r,JoinHint.Left);
I then create a datatable using GetMultiAsDataTable. It's at this point I noticed in the generated SQL that I'm getting a RIGHT JOIN and not a LEFT JOIN.
It doesn't seem to matter what the RelationType is, but if I swap the leftField and rightField round I still get a Right Join but the views are swapped the right wayround so I get the data I want.
Is this what's supposed to happen 'cos it seems backwards to me?
(I know ( B RightJoin A) is the same as ( A LeftJoin B) )
Thanks
Mark