简体   繁体   English

C# - PostgreSQL(NpgSql)bytea数据传输进度

[英]C# - PostgreSQL (NpgSql) bytea data transfer progress

Dear Stack Overflow community, 亲爱的Stack Overflow社区,

I am using PostgreSQL databases from C# with the NpgSql .Net connector. 我正在使用C#中的PostgreSQL数据库和NpgSql .Net连接器。

I want to have a progress bar when I transfer a bytea to and from a PostgreSQL. 当我将一个bytea传入和传出一个PostgreSQL时,我希望有一个进度条。 I have searched a lot but I cannot find any possible work around. 我搜索了很多,但我找不到任何可能的工作。

What I use is a PostgreSQL function that inserts or retrieve a file stored in a bytea column. 我使用的是PostgreSQL函数,它插入或检索存储在bytea列中的文件。 Perhaps, I can store the file size when I upload it from my application to set the ProgressBar.Maximum property, but I do not know how to see the current amount of bytes transferred in the NpgsqlConnection (or NpgsqlCommand). 也许,当我从应用程序上传它以设置ProgressBar.Maximum属性时,我可以存储文件大小,但我不知道如何查看NpgsqlConnection(或NpgsqlCommand)中传输的当前字节数。

Thank you very much in advanced, Ignacio. 非常感谢先进的Ignacio。

Dear Stackoverflow community , 亲爱的Stackoverflow社区

I have asked this question in the pgFoundary and Francisco kindly answered my questions as follows. 我在pgFoundary中问了这个问题,弗朗西斯科回答了我的问题如下。 I want to share it with you. 我想和你分享。


Regarding your question, I think this isn't possible because Npgsql doesn't report back how many bytes have been written to the database while sending the data. 关于你的问题,我认为这是不可能的,因为Npgsql不会报告在发送数据时已经写入数据库的字节数。

One possible workaround would you to use the Large Object support ( you can find a working example in manual.npgsql.org ) where your application would send bytes in blocks so you could update your UI about the progress. 一种可能的解决方法是使用大对象支持(您可以在manual.npgsql.org中找到一个工作示例),其中您的应用程序将以块的形式发送字节,以便您可以更新有关进度的UI。


Thank you, Ignacio. 谢谢你,伊格纳西奥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM