相关疑难解决方法(0)

DataContext使用.NET 4编译查询问题

我的项目(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
Run Code Online (Sandbox Code Playgroud)

每当我运行我的查询时,我都会传递我的上下文

return StaticQueries.getTopFiveOrders(mContext, int howMany);


public static Func<Mycontext, int, IQueryable<Order>> getTopFiveOrders
            = CompiledQuery.Compile
                ((Mycontext mContext, int howMany) =>
                 ( some query).Distinct());
Run Code Online (Sandbox Code Playgroud)

第二个请求发生错误.

datacontext .net-4.0 linq.compiledquery linq-to-sql

6
推荐指数
1
解决办法
2287
查看次数