我正在尝试使用dapper orm,最近他们添加了asyncquery支持.我对此进行了谷歌搜索.如果您的网站上的流量很大,那就太好了.我正在尝试使用postgressql和dapper.现在,在连接中,如果我传递简单的连接字符串,则可以正常工作.但是根据几篇文章,如果我想使用异步,那不是真正的异步,我需要异步连接字符串.
I was trying dapper orm and recently they added asyncquery support. I googled it about that. It is wonderful if you have heavy traffic on your site. I was trying that with postgressql and dapper. Now, in connection if I am passing simple connection string it works fine. But as per couple of articles it is not true async if I want to use it, I need async connection string.
现在,我不知道如何与Postgresql和npgsql一起使用.这是参考,作者解释了如何使用Sql Server.
Now, I don't know how to use with Postgresql and npgsql. Here is complete article for reference where author explains how to do it with Sql Server.
如果我想要与Postgresql一样,该怎么办?
What I need to do if I want same with Postgresql?
请让我知道是否还有其他要求.
Please let me know if any further requirement needed.
推荐答案本文的作者有些错误-在.NET 4.5中, AsynchronousProcessing 属性会被忽略,因为不再需要该属性.您可以直接启动调用SqlClient的Async方法,而无需任何特殊的连接字符串
The author of this article is somewhat wrong - in .NET 4.5 the AsynchronousProcessing property is ignored because it is no longer required. You can just start calling the Async methods of SqlClient without any special connection strings.
操作是否将异步执行,取决于数据库提供程序.例如, DbCommand.ExecuteDbDataReaderAsync 实际上同步执行并阻塞调用线程.SqlCommand重写此方法并异步执行.
Whether the operations will execute asynchronously, depends on the database provider. For example, the default implementation of DbCommand.ExecuteDbDataReaderAsync actually executes synchronously and blocks the calling thread. SqlCommand overrides this method and executes asynchronously.
不幸的是,NpgsqlCommand不会重写此方法,因此您只能进行同步执行.
Unfortunately, NpgsqlCommand doesn't override this method so you are left with synchronous execution only.
更多推荐
使用npqsql与PostgreSQL和dapper进行AsyncQuery
发布评论