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

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

问题描述

相比,将L2S与新的C#5 async/await关键字一起使用的最佳实践是什么?这种方法?在网上找不到任何内容.

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没有异步/等待支持,但是开放源代码版本正在这里积极研究各种可能性.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.

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

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