假设我遇到了这种情况:我必须使用从存储过程中获得的数据过滤我的一个实体:
var results = from c in db.Customer
join p in db.GetSPResults() on c.Id equals p.Id
select c;
在我的 Context 课上,我得到了这个:
public ObjectResult<Example> GetSPResults()
{
return (this as IObjectContextAdapter).ObjectContext.ExecuteFunction<Example>("Proc_Example");
}
到目前为止,我遇到了两个问题:
当代码到达 ExcecuteFunction 行时,我得到一个 InvalidOperationException:
在容器 'xxx' 中找不到 FunctionImport 'xxx'。
假设你们可以帮助我解决这个问题,是否可以这样查询?像上下文实体一样使用那些存储过程结果?我认为 EF 不允许这样做,因为它不是实体,也不是“常量值”。
我正在使用 EF 4.3。