问题描述
我了解 .NET 4.5 提供了一系列功能,使异步数据库操作更易于实现.MSDN 说,如果连接字符串未设置为异步工作,ADO.NET 的任何异步方法都不会以异步方式工作.因此 SqlConnectionStringBuilder 带有一个名为 AsynchronousProcessing 的属性.
I understand that .NET 4.5 comes with a bunch of features to make asynchronous database operations easier to implement. MSDN says that if the connection string is not set to work asynchronously none of the async methods of ADO.NET will work in an asynchronous way. Therefore SqlConnectionStringBuilder comes with a property called AsynchronousProcessing.
我想知道这些异步功能是否也适用于其他数据库服务器(例如 mysql)?我应该怎么做才能使 aync 与 .NET 无法识别的非 SQL 数据库一起工作?(例如 RavenDB)?
I am wondering if these async features will work with other database servers (e.g. mysql) as well? What should I do to make aync work with a no-SQL database that is not recognized by .NET? (e.g. RavenDB)?
推荐答案
所有驱动的异步方法都定义在 DbDataReader 中,例如 DbDataReader.ReadAsync.由特定的驱动程序使用特定的实现来覆盖这些方法,以利用每个数据库的异步特性并使用例如.一个自然的异步操作,而不是包装在线程中的同步操作.
The asynchronous methods for all drivers are defined in DbDataReader, eg DbDataReader.ReadAsync. It is up to the specific drivers to override these methods with specific implementations to take advantage of the asynchronous characteristics of each database and use eg. a naturally asynchronous operation instead of a synchronous operation wrapped in a thread.
也就是说,MySQL Connector/Net 6.8 增加了对 Entity Framework 6 中的异步操作,但 MySqlDataReader 类不提供 ReadAsync
方法.这是因为 Connector 使用旧的体系结构(2.0 之前),实现 IDataReader 接口,而不是从 .NET 2.0 中引入的通用 DbDataReader 类派生.
That said, MySQL Connector/Net 6.8 adds support for asynchronous operations in Entity Framework 6 but the MySqlDataReader class does NOT provide a ReadAsync
method. This is because Connector uses an old architecture (pre-2.0), implementing the IDataReader interface instead of deriving from the generic DbDataReader class introduced in .NET 2.0.
这篇关于.NET 4.5 的异步功能是否也适用于 MySql 和其他数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!