我使用实体框架 4.0。是否有可能SaveChanges()
返回 0 但不抛出异常?比如添加之后。
这是我的代码:
try
{
_context.CodeProducts.Add(entity);
_context.SaveChanges();
//Shell I control return result from SaveChanges() in here.
//However doesn't throw an exceoption?
return new MethodResponse()
{
ResultText = "Successful",
Type = MethodResponse.ResponseType.Succeed
};
}
catch (OptimisticConcurrencyException exc)
{
throw exc;
}
catch (UpdateException exc)
{
throw exc;
}
catch (Exception exc)
{
throw exc;
}