如果我的条件失败为rdr.HasRows == true
,我该如何回应我的控制器失败
public Employee DeleteEmpById(int key)
{
try
{
SqlCommand cmd = new SqlCommand("Sp_GetEmployeeById", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmpId", key);
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows == true)
{
}
else
// Here what I mention when rdr.HasRows false
}
控制器
public ActionResult DeleteById(int id)
{
var x = ObjRepo.DeleteEmpById(id);
return View(x);
}