我想将新的 async wait 功能应用到实体模型中导入的存储过程/函数导入,但目前还无法使用 EF6 alpha。
是否可以在 EF6 alpha2(或自 20211 起的夜间构建)中调用返回复杂类型集合的实体函数导入(调用 SQL 存储过程)上的任何新异步方法?例如
private async Task<IList<Company>> getInfo (string id)
{
using (CustomEntity context = new CustomEntity())
{
var query = await context.customStoredProcedure(id).ToListAsync();
// ".ToListAsync()" method not available on above line
// OR ALTERNATIVELY
var query = await (from c in context.customStoredProcedure(id)
select new Company
{
Ident = c.id,
Name = c.name,
Country = c.country,
Sector = c.sector,
etc. etc....
}).ToListAsync();
// ".ToListAsync()" method or any "...Async" methods also not available this way
return query;
}
}
“ToListAsync”或任何新的异步修改方法似乎不适用于上述实体存储过程/函数导入;只有标准的“ToList”或“AsNumerable”等方法可用。
我遵循了这个(http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6)以确保代码引用新的 EF6 dll 而不是 EF5,并更新了各种 using 语句。除了上面的内容之外,一切都正确构建。 (.NET 框架 4.5)
我唯一能看到异步方法的情况是,我不仅从数据库导入存储过程,还导入一个表——然后,当通过上面的实体上下文 (context.SomeTable) 引用该表时,一些异步方法出现在智能感知中。
我真的很想在将数据作为 JSON 返回之前开始在多个存储过程上使用新的 async wait 功能,但到目前为止还无法让它工作。
难道我做错了什么?实体存储过程/函数导入无法使用异步功能吗?谢谢你的建议。