如何使用 .net core DBFunction 将行作为参数传递给 Postgres 函数

How to pass a row as a parameter to a Postgres function using .net core DBFunction

使用 c# .net 核心将 pgsql table 对象作为参数传递?

HI 在 pgsql 中我们可以传递 table 行作为参数,我想知道我们如何在 .net core 中使用它?

像下面的函数接受一些参数并赋予其功能

   -CREATE OR REPLACE FUNCTION public."GetUserName"(u "User_", pmed "Pharmacy", puser "Pharmacy", m "Medication")
 RETURNS character varying
 LANGUAGE plpgsql
AS $function$
BEGIN
    return (
        case when u."Id" > 0 then
            (
                u."FirstName" || ' ' ||coalesce(u."LastName", '')
                || (
                    case when u."Pharmacy_Id" > 0 then
                            (case when puser."PharmacyId" > 0 then ' (' || puser."PharmacyName" || ') ' else '' end)
                    else '' end
                )
            )
        when coalesce (u."Id" , 0) = 0 then pmed."PharmacyName" else '' end
    );
END
$function$
;

我想使用 .net core ef core 调用此函数,而不使用 DbFunctions appraoch 进行动态查询

与其尝试将整行作为参数传递给函数(这通常效率不高),不如尝试传递该行的主键。然后,您的函数可以像往常一样对该行执行任何查询或更新。

一般来说,在关系数据库中,一行不作为您传递或操作的实体存在(尽管 PostgreSQL 确实有 1st-class 对复合类型的支持,它也支持表)。