小编bur*_*zan的帖子

如何使用 dapper 执行 postgres 函数

当我尝试使用 dapper 调用 postgre 函数时出现错误。我哪里做错了?如果你能帮助我,我会很高兴。

错误信息:

 availability_list(facilityId => integer, startDate => timestamp without time zone, endDate => timestamp without time zone) does not exist"
Run Code Online (Sandbox Code Playgroud)

使用 Dapper 调用 postgre 函数:

var func = "public.availability_list";

var result = db.Query<ReportResponse>(
            sql: func,
            param: new { facilityId = request.FacilityId, startDate = 
            DateTime.Now, endDate = DateTime.Now },
            commandType: CommandType.StoredProcedure, 
            commandTimeout: 900) as List<ReportResponse>;
Run Code Online (Sandbox Code Playgroud)

我的 Postgre 函数:

CREATE FUNCTION Availability_List(facilityId int, startDate date, endDate date)
RETURNS report_type[] 
AS 
$$

DECLARE
result_record report_type[];

BEGIN

result_record := array( …
Run Code Online (Sandbox Code Playgroud)

c# postgresql stored-procedures dapper .net-core

5
推荐指数
1
解决办法
6929
查看次数

标签 统计

.net-core ×1

c# ×1

dapper ×1

postgresql ×1

stored-procedures ×1