I'm getting an error when trying to join against multiple tables in a query:
The specified LINQ expression contains references to queries that are associated with different contexts
It's confusing because it makes it seem like I'm using different contexts within the query but I'm not:
public static IQueryable<Company> GetAll(bool supportsMMAT)
{
return from c in Context.Companies
join v in Context.Vehicles on c.CompanyIdNumber equals v.CompanyIdNumber
join mt in Context.ModemTypes on v.ModemTypeId equals mt.Id
where !c.CompanyShutOff
&& (!supportsMMAT || mt.Model == "MMAT")
select c;
}
Any ideas? I'm using the EF4 CTP5 code first approach, if that makes any difference...
This can happen if your Context property returns a new instance every time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With