【发布时间】:2012-06-21 06:55:50
【问题描述】:
我使用实体框架 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;
}
【问题讨论】:
-
您需要添加更多信息,否则没人能提供帮助。你能发布你的代码吗?
标签: c# asp.net entity-framework c#-4.0 entity-framework-4