EF Core:如何从具有 refcursor 返回类型的 PostgreSQL 函数中获取结果

问题描述 投票:0回答:0

我在 PostgreSQL 中有这个功能:

CREATE OR REPLACE FUNCTION public."test"(ref refcursor, in id int) 
RETURNS refcursor AS $$
BEGIN
  OPEN ref FOR 
    SELECT *
    FROM "table"
    WHERE "Id" = @id;
  RETURN ref;
END;
$$ LANGUAGE plpgsql;

你通常从 SQL 中的这个函数得到结果是这样的:

select public."test"('my_cursor', 1);

fetch all in "my_cursor";

我想从 EF Core 中的这个函数获得结果,但不知道如何做。我试图在

context.Table.FromSqlInterpolated()
中执行选择和全部获取,但它给出了
The required column 'Id' was not present in the results of a 'FromSql' operation.
错误,我认为这是因为第一个 SQL 命令只返回游标名称。我无法创建视图,因为它有一个参数。

我该怎么做?

.net postgresql entity-framework-core npgsql
© www.soinside.com 2019 - 2024. All rights reserved.