table 名称大写时 nlog 没有插入数据库

nlog didnt insert database when table name uppercase

这很好用;

<targets>
    <target name="database" xsi:type="Database"
            dbProvider="Npgsql.NpgsqlConnection, Npgsql"
            connectionString="User ID=postgres;Password=xxx;Host=192.xx;Port=5432;Database=xxx;">
      <!--Pooling=true;-->
      <commandText>
        insert into systemlogs(...;
      </commandText>

但当更改为 table 时名称为

"SystemLogs"

(同样在数据库中完成)它抛出异常; "couldnt find table name "系统日志

这没有道理,但为什么 nlog 没有意识到更新的 table 名称?

在 PostgreSQL 中,所有带引号的标识符(例如 table 和列名)都区分大小写:

参见:PostgreSQL 列名是否区分大小写?

所以 NLog 找不到它们是因为您使用了引号和错误的大小写。

所以不要使用引号或使用正确的大小写

如果您在双引号内将 table 名称指定为 "SystemLogs",那么您也需要这样使用它:

insert into "SystemLogs" ...

在 Postgresql 中,引用的标识符保留它们被引用的大小写,并且需要以相同的方式引用。如果您创建不带引号的名称 SystemLogs,那么它将折叠为小写。详情见下文:

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS