如何从sql存储过程到实体框架捕获RAISEERROR或SQL 2012 - THROW异常 - 存储过程调用?
using (Entities context = new Entities())
{
IEnumerable<EmployeeDetails> empDetails = context. Database.SqlQuery
< EmployeeDetails >("exec GetEmployeeData ", null).ToList();
}
答案 0 :(得分:0)
尝试/抓住?
using (Entities context = new Entities())
{
try
{
IEnumerable<EmployeeDetails> empDetails = context. Database.SqlQuery <EmployeeDetails>("exec GetEmployeeData ", null).ToList();
}
Catch (SqlException ex)
{
//Do something
}
}