2014-10-04 162 views
8

我试图通过缓存查询来提高Web应用程序的性能。实体框架6编译LINQ查询

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类型参数“TArg0”。 Objects.CompiledQuery.Compile(System.Linq.Expressions.Expression>)”。没有从'myEntity'到'System.Data.Entity.Core.Objects.ObjectContext'的隐式引用转换。

我使用EF6

+0

您需要'ObjectContext'对象作为'Compile'方法的第一个类型参数。 – Ofiris 2014-10-04 12:06:42

回答