使用npqsql与PostgreSQL和dapper进行AsyncQuery

编程入门 行业动态 更新时间:2024-10-28 18:29:10
本文介绍了使用npqsql与PostgreSQL和dapper进行AsyncQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用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

本文发布于:2023-10-22 22:08:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PostgreSQL   npqsql   AsyncQuery   dapper

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!