小编abh*_*rma的帖子

升级 .NET Core 时 Postgres 功能不起作用

当我们将 .net core 和其他软件包升级到最新版本时,Postgres 功能无法正常工作。早些时候,相同的代码运行得很好。

我们使用函数而不是存储过程。

DbTransaction transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);

try
{
        using (DbCommand command = connection.CreateCommand())
        {
            command.Transaction = transaction;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = Constants.StoredProcedure.SPNAME;
            command.Parameters.Add(new NpgsqlParameter("Param1", NpgsqlTypes.NpgsqlDbType.Integer)
            { Value = val1 });
            command.Parameters.Add(new NpgsqlParameter("Param2", NpgsqlTypes.NpgsqlDbType.Varchar)
            { Value = val2 });
            command.Parameters.Add(new NpgsqlParameter("Param3", NpgsqlTypes.NpgsqlDbType.Varchar)
            { Value = val3 });
            var res = command.ExecuteScalar();
            transaction.Commit();
}}
Run Code Online (Sandbox Code Playgroud)

错误 - Npgsql.PostgresException:'42809:public.NotableEventUserModeratorJoinOrder(Param1 => 整数,Param2 => 字符变化,Param3 => 字符变化)不是过程

我们注释了行command.CommandType = CommandType.StoredProcedure;,然后收到错误 - PostgreSQL,Npgsql 返回 42601:语法错误

postgresql npgsql

0
推荐指数
1
解决办法
1015
查看次数

标签 统计

npgsql ×1

postgresql ×1