我的项目(UI 层是 asp.mvc)是使用 .NET 3.5 开发的。升级到 .NET 4.0 后,我遇到了编译查询的问题:
[ArgumentException: Query was compiled for a different mapping source than the one associated with the specified DataContext.]
System.Data.Linq.CompiledQuery.ExecuteQuery(DataContext context, Object[] args) +863348
System.Data.Linq.CompiledQuery.Invoke(TArg0 arg0, TArg1 arg1) +110
每次运行查询时,我都会传递上下文
return StaticQueries.getTopFiveOrders(mContext, int howMany);
public static Func<Mycontext, int, IQueryable<Order>> getTopFiveOrders
= CompiledQuery.Compile
((Mycontext mContext, int howMany) =>
( some query).Distinct());
错误发生在第二个请求上。