实体框架6编译的LINQ查询

12

我正在尝试通过缓存查询来提高 Web 应用程序的性能。

    public static Func<myEntity, List<HASHDuplicates>, IQueryable<FormResponse>> CompiledDuplicatedResponses =
    CompiledQuery.Compile<myEntity, List<HASHDuplicates>, IQueryable<FormResponse>>(
    (db, hashes) => from r in db.FormResponse
                    from h in db.IndexHASHes
                    from d in hashes
                    where r.id == h.FormResponseID && h.IndexHASHString == d.hash
                    select r);

我在编译时收到以下错误:

类型“myEntity”无法用作泛型类型或方法“System.Data.Entity.Core.Objects.CompiledQuery.Compile(System.Linq.Expressions.Expression>)”中的类型参数“TArg0”。从“myEntity”到“System.Data.Entity.Core.Objects.ObjectContext”的隐式引用转换不存在。

我正在使用EF6


你需要将ObjectContext对象作为Compile方法的第一个类型参数。 - Ofiris
1个回答

19

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接