Reputation: 896
Passing pgsql table object as parameter using c# .net core?
HI in pgsql we can pass table row as parameter , I want to know how we can use it in .net core?
like below function takes some parameters and give its functionality
-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$
;
I want to call this function using .net core ef core without dynamic queries using DbFunctions appraoch
Upvotes: 0
Views: 657
Reputation: 16692
Rather than trying to pass an entire row as a parameter to a function - which usually wouldn't be very efficient - try passing the primary key of that row instead. Your function can then perform any queries or updates on that row as usual.
In general, in relational databases a row doesn't exist as an entity you pass around or manipulate as such (although PostgreSQL does have 1st-class support for composite types, which also back tables).
Upvotes: 1