使用新的 async/await 异步使用 Linq to Sql [英] Using Linq to Sql asynchronously with new async/await

查看:37
本文介绍了使用新的 async/await 异步使用 Linq to Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个 方法?在网络上找不到任何内容.

What are best practices to use L2S with new C# 5 async/await keywords comparing to this approach? Couldn't find any on web.

推荐答案

EF 5 没有 async/await 支持,但开源版本正在积极探索这里的可能性.EF 中的异步支持记录在 http://msdn.microsoft.com/en-us/data/jj819165.aspx.它不会在结果被水合时流式传输(正如您在 RX 中发现的那样),但它确实使数据库调用异步.

EF 5 does not have async/await support, but the open source version is actively looking into possibilities here. the Async support in EF is documented at http://msdn.microsoft.com/en-us/data/jj819165.aspx. It doesn't stream the results in as they are hydrated (as you would find with RX) but it does make the database calls asynchronous.

至于 LINQ to SQL,除了将您的请求包装在 Task.Factory.Start 操作中之外,我不会屏住呼吸希望 Microsoft 为 Linq 实现基于任务的异步(异步/等待所需)SQL.

As for LINQ to SQL, outside of wrapping your request in a Task.Factory.Start operation, I wouldn't hold my breath hoping that task based async (required for async/await) will be implemented by Microsoft for Linq to SQL.

您可以使用 IQToolkit 并在绝对必要时扩展它添加您自己的异步支持.此外,Mono 已经实现了 LINQ to SQL,您可以使用异步支持对其进行扩展.

You could use the IQToolkit and extend it adding your own async support if absolutely necessary. Also, Mono has implemented LINQ to SQL which you might be able to extend with async support.

这篇关于使用新的 async/await 异步使用 Linq to Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆