开发者

The specified LINQ expression contains references to queries that are associated with different contexts

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 s开发者_如何学Gotatic 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜