2014-10-04 161 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

回答