I am trying to join two tables.
The TSQL would be:
SELECT *
FROM User u INNER JOIN Hierarchy h ON u.OrganisationId = h.OrganisationId
OR u.OrganisationId = h.OwnerOrganisationId
I have searched and no one has an answer for this with fluent. The closest I can think of is this:
var join1 = context.User.Join(context.Hierarchy, u => u.OrganisationId, h => h.OrganisationId, uh => new {u, h});
var join2 = context.User.Join(context.Hierarchy, u => u.OrganisationId, h => h.OwnerOrganisationId, uh => new {u, h});
var desiredResult = join1.Union(join2);
This seems like it could be highly inefficient though.