gpt4 book ai didi

postgresql - 如何从 Dapper(使用 Npgsql)调用具有混合大小写名称的存储过程?

转载 作者:行者123 更新时间:2023-11-29 14:18:31 24 4
gpt4 key购买 nike

从 NuGet,我正在使用

...\packages\Npgsql.2.2.5\lib\net45\Npgsql.dll

...\packages\Dapper.1.42\lib\net45\Dapper.dll

在 PostgreSQL 中调用存储过程时,我需要将过程名称的大小写保留为

var x = cnn.Query<icd9>("GetDxLibrary", commandType: CommandType.StoredProcedure);

我收到运行时错误:

An unhandled exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll

Additional information: ERROR: 42883: function getdxlibrary() does not exist.

如果将 PostgreSQL 中的函数重命名为 getdxlibrary(),一切顺利。

如何在 Dapper 中调用具有混合大小写名称的过程?

TIA

最佳答案

只需在您的函数名称周围添加引号:

var x = cnn.Query<icd9>("\"GetDxLibrary\"", commandType: CommandType.StoredProcedure);

PostgreSQL 自动将所有非引号标识符小写,因此当您向它发送 GetDxLibrary 时,它实际上看到的是 getdxlibrary。

关于postgresql - 如何从 Dapper(使用 Npgsql)调用具有混合大小写名称的存储过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38749000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com