EF6调用存储过程参数不运行?

时间:2018-01-31 16:24:34

标签: c# oracle entity-framework oracle11g

我很难让Oracle存储过程运行一些返回值。我想我已经接近但是我收到了以下错误:

  

执行命令时,参数必须是数据库参数或值。

我会说我从来没有使用EF来调用带有输出参数的存储过程,所以我确定我设置的内容不正确但它看起来虽然代码应该可行。

using (var ctx = new DataContext())
{
    DateTime shiftStartDate = DateTime.Parse(startDateTime);
    DateTime shiftEndDate = DateTime.Parse(endDateTime);

    var empId = new OracleParameter("empId", OracleDbType.Varchar2, employeeId, ParameterDirection.Input);
    var startDate = new OracleParameter("startDate", OracleDbType.Date, shiftStartDate, ParameterDirection.Input);
    var endDate = new OracleParameter("endDate", OracleDbType.Date, shiftEndDate, ParameterDirection.Input);
    var swapEmpId = new OracleParameter("swapEmpId", OracleDbType.Varchar2, swapEmployeeId, ParameterDirection.Input);
    var IsValid = new OracleParameter("Valid", OracleDbType.Varchar2, ParameterDirection.ReturnValue);
    var Remarks = new OracleParameter("Remarks", OracleDbType.Varchar2, ParameterDirection.ReturnValue);

    var results = ctx.Database.ExecuteSqlCommand("VALIDATE_CS_POLICY  :empId, :startDate, :endDate, :swapEmpId, :Valid, :Remarks", employeeId, startDateTime, endDateTime, swapEmployeeId, IsValid, Remarks);

    string resultIsValid = IsValid.Value.ToString();
    string resultRemarks = Remarks.Value.ToString();
}

这就是我作为存储过程声明给出的内容

PROCEDURE SCHEMANAME.VALIDATE_CS_POLICY (EMPID CHAR, CS_START DATE, CS_END DATE, SWAP_EMPID CHAR, VALID OUT CHAR, REMARKS OUT VARCHAR) 

0 个答案:

没有答案