Unable to hit oracle stored proc using .Net EF(2.2) Core repository pattern

送分小仙女□ 提交于 2020-04-18 00:50:47

问题


ORA-00900: invalid SQL statement

This is the error i get when i am trying to hit a stored procedure(in Oracle) from my API.

I am using Repository pattern with Entity framework.(EF Core 2.2)

This is my call,

return FetchWithStoredProcedure("PROC_GETMYPROC",
     new OracleParameter("PARAM1", OracleDbType.Int32, ParameterDirection.Input) { Value = PageNo },
     new OracleParameter("PARAM2", OracleDbType.Int32,ParameterDirection.Input) { Value = PageSize },
     new OracleParameter("PARAM3", OracleDbType.Varchar2, 30, ParameterDirection.Input) { Value = SearchTerm },
     new OracleParameter("PARAM4", OracleDbType.Int32, ParameterDirection.InputOutput) { Value = TotalRows },
     new OracleParameter("PARAM5",OracleDbType.RefCursor, ParameterDirection.Output)
                     ).ToList();

This is my FetchWithStoreProcedure method

public IEnumerable<T> FetchWithStoredProcedure(string query, params object[] parameters)
{
    return _entities.Set<T>().FromSql(query, parameters);
}

And this is the exception thrown.


回答1:


Kindly try like the below

      return FetchWithStoredProcedure("BEGIN PROC_GETMYPROC(@PARAM1,@PARAM2,@PARAM3
       ,@PARAM4,@PARAM5); END",


来源:https://stackoverflow.com/questions/60953138/unable-to-hit-oracle-stored-proc-using-net-ef2-2-core-repository-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!