Dapper 参数不能通过 npgsql 连接与 PostgreSQL 一起使用,是否支持 postgres 匿名函数参数化?

Dapper parameters not working with PostgreSQL through npgsql connection, is postgres anonymous function parameterization supported?

我正在尝试使用 dapper 来参数化我为执行更新插入而编写的 postgres 匿名函数。这是代码:

private static int UpsertProductPrice(
        IDbConnection connection,
        Data.ProductPrice price,
        List<Data.ProductPriceTier> priceTiers)
    {
        string postgres = @"DO $$
        BEGIN 
        UPDATE product_price 
            SET start_date = @StartDate, end_date = @EndDate, price_tier_type = @PriceTierType
            WHERE product_price_external_id = @Id;
        IF found THEN
            RETURN;
        END IF;
        BEGIN
            INSERT INTO product_price(product_price_external_id, start_date, end_date, price_tier_type) 
            VALUES (@Id, @StartDate, @EndDate, @PriceTierType);
            RETURN;
        EXCEPTION WHEN unique_violation THEN END; END$$;";

        int productPriceId = connection.Execute(
            postgres,
            new { Id = price.product_price_external_id, StartDate = price.start_date, EndDate = price.end_date, PriceTierType = price.price_tier_type });

Postgres 将查询记录为未参数化:仍有 @ 符号且未插入任何值。这是日志。

2015-07-15 14:57:58.570 EDT,"user","TestDb",8496,"::1:53953",55a6ad36.2130,1,"DO",2015-07-15 14:57:58 EDT,9/42,0,ERROR,42703,"column ""startdate"" does not exist",,,"UPDATE product_price 

            SET start_date = @StartDate, end_date = @EndDate, price_tier_type = @PriceTierType

            WHERE product_price_external_id = @Id",52,"PL/pgSQL function inline_code_block line 3 at SQL statement","DO $$

        BEGIN 

        UPDATE product_price 

            SET start_date = @StartDate, end_date = @EndDate, price_tier_type = @PriceTierType

            WHERE product_price_external_id = @Id;

        IF found THEN

            RETURN;

        END IF;

        BEGIN

            INSERT INTO product_price(product_price_external_id, start_date, end_date, price_tier_type) 

            VALUES (@Id, @StartDate, @EndDate, @PriceTierType);

            RETURN;

        EXCEPTION WHEN unique_violation THEN END; END$$;",,,""

我是做错了什么,还是不支持?我找不到任何人尝试在线执行此操作。

不支持匿名代码块中的参数,这将是 PostgreSQL 功能而不是 Npgsql 功能。请参阅此处的讨论:https://github.com/npgsql/npgsql/issues/629