【发布时间】:2020-09-11 04:51:28
【问题描述】:
我正在尝试通过 EF 核心在 postgresql 中使用函数和存储过程。我通过编写 ef 迁移文件创建了一个函数并更新了我的数据库。我可以看到我的函数是在 db 上创建的,当我在 Pgadmin 中运行“select public.sp_Get_Products()”时,我得到了正确的结果。
但是当我尝试通过 EF 核心获取结果时,下面的代码会返回给我:-1
_context.Database.ExecuteSqlCommand("select public.sp_Get_Products()");
如果我尝试使用下面的 FromSqlRaw,它会返回 The required column 'Id' was not present in the result of a 'FromSql' operation
_context.Product.FromSqlRaw("select public.sp_Get_Products()");
所以我仍然无法找到一种方法来通过函数从 postgresql 中获取我的选择结果。
【问题讨论】:
标签: postgresql .net-core entity-framework-core npgsql sql-function