我有一个MVC 5项目,我正在试图弄清楚如何调用具有输出参数的Oracle存储过程。我已经做了一些搜索,这是我最接近的但是我得到一个错误,它是无效的SQL。
即使我让它成功运行,我假设它会将输出值传递给结果对象并填充IsValid和Remarks属性?
public class ValidateCSPolicyResult
{
public string IsValid { get; set; }
public string Remarks { get; set; }
}
using (var ctx = new DataContext())
{
var empId = new SqlParameter("@empId", employeeId);
var startDate = new SqlParameter("@startDate", startDateTime);
var endDate = new SqlParameter("@endDate", endDateTime);
var swapEmpId = new SqlParameter("@swapEmpId", swapEmployeeId);
var isValid = new SqlParameter
{
ParameterName = "Valid",
Value = "N",
Direction = ParameterDirection.Output
};
var remarks = new SqlParameter
{
ParameterName = "Remarks",
Value = "",
Direction = ParameterDirection.Output
};
var results = ctx.Database.SqlQuery(ValidateCSPolicyResult)("VALIDATE_CSW_POLICY @empId, @startDate, @endDate, @swapEmpId, @Valid out, @Remarks out").FirstOrDefault();
}