As it’s (at this moment) impossibe to use Include() in a compiled query, I’m trying to rewrite them to joins. But it doesn’t seem to work out quite as I would want it to.
Say I have this relation:
Order OrderState
Id Id
OrderStateId Description
Now I used to fetch the description as follows:
var q = (from o in context.Orders
where o.Id = orderId
select o).Include("OrderState");
I’ve tried rewriting this as:
var q = (from o in context.Orders
join st in context.OrderStates on o.OrderStateId equals st.Id
where o.Id = orderId
select o);
But the OrderState is still null in my resultset. How would I go about fixing this (in a way that;s acceptable for compiled query)?
If you can’t use
.Include, you need to actually includeo.OrderStatesomewhere in the result, so how about this?o.Order.OrderStateshould get hooked up too.OrderStatewithout extra help for each result inq.