我为我的代码优先实体模型编写了以下编译查询。但是,我需要帮助才能正确编译。下面是我的类的代码,然后是我为查询 BudgetContext 对象以获取此信息而编写的已编译查询
[DataContract]
public class BudgetSummary : IBudgetSummary, IEntity
{
public int Id{ get()}
public int MDACode{ get; set; }
public DateTime BudgetYear{ get; set; }
public virtual IList<IBudgetItem> budgetitems{ get; set; }
}
public class BudgetContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<BudgetItem> BudgetItems { get; set; }
public DbSet<BudgetLineItem> BudgetLineItems { get; set; }
public DbSet<IBudgetSummary> BudgetSummaries { get; set; }
public DbSet<MDA> MDAs { get; set; }
}
static readonly Func<BudgetContext, int, IQueryable<BudgetSummary>> FindBudgetSummaryCompiledQuery =
CompiledQuery.Compile<BudgetContext,int, IQueryable<BudgetSummary>>(
(ctx, mdaID) => from budgetsummary in ctx.BudgetSummaries
where budgetsummary.MDACode >= mdaID
select budgetsummary);
无法将 lambda 表达式转换为委托类型“System.Func>”,因为块中的某些返回类型不能隐式转换为委托返回类型