升级到EF4 CTP5后,以前工作(使用CTP4)LINQ动态查询库会引发以下异常
Unable to cast object of type 'System.Data.Entity.Infrastructure.DbQuery' to type 'System.Linq.IQueryable`1[KIT.TAM.Core.Entities.TravelAgent]'.
在下面的退货声明中:
namespace System.Linq.Dynamic
{
public static class DynamicQueryable
{
public static IQueryable<T> Where<T>(this IQueryable<T> source, string predicate, params object[] values)
{
return (IQueryable<T>)Where((IQueryable)source, predicate, values);
}
}
}
是否有适用于EF4 CTP5的库的更新版本?
谢谢大家 .
1 回答
解决了这个问题 . 在DynamicLibrary.cs中:
I replaced
with
这是基本相同的代码
但改为
source.Provider.CreateQuery()
为source.Provider.CreateQuery<T>
.您还必须为静态方法
OrderBy<T>
执行此操作 .