postgresql - Npgsql - 通知事件并附加有效负载
问题描述
NOTIFY
使用psql 方法时是否可以接收有效负载?
现在我正在使用
using (var cmd = new NpgsqlCommand("NOTIFY test", conn)) {
cmd.ExecuteNonQuery();
}
但我想在NOTIFY
活动中附上一条消息
澄清
using (var cmd = new NpgsqlCommand("NOTIFY test_channel, test_message", conn)) {
cmd.ExecuteNonQuery();
}
这会引发错误
Exception has occurred: CLR/Npgsql.PostgresException
An exception of type 'Npgsql.PostgresException'
occurred in System.Private.CoreLib.dll
but was not handled in user code: 'External component has thrown an exception.'
解决方案
正如 PostgreSQL 文档所示,您可以包含任意有效负载字符串:
通知测试,有效载荷
推荐阅读
- terraform - cdkt 创建多个堆栈
- flutter - 根据布尔值显示或隐藏文本小部件
- google-cloud-platform - 从对话流发送和接收文本数据
- .net - HttpWebRequest 失败:底层连接已关闭:无法为 SSL\/TLS 安全通道建立信任关系
- json - 使用 spark/scala 将 JSON 文件加入数据框
- c# - EFCore - 从 DbSet 中的集合列表中获取特定属性
- mfc - 如何获取浮动工具栏的大小
- mysql - 我正在尝试对 MySQL 5.0 中的变量进行一些简单的操作,但我无法让它正常工作
- mongodb - 从数组中提取聚合结果
- spring - 将 Web 应用程序从 Java 8 迁移到 11 以及将 JEE 迁移到 JakartaEE 时遇到问题 - jaxb 遇到问题