私のプロジェクト (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());
2 番目の要求でエラーが発生します。