try
{
using (IDbConnection connection = InsDALFactory.Product.GetOpenedConnection())
{
using (IDbTransaction trans = connection.BeginTransaction())
{
trans.Commit();
return new InsReturnMessage();
}
}
}
catch (Exception expt)
{
WuhanIns.Framework.Core.ExceptionHandlerHelper.HandleException(expt);
return new InsReturnMessage(expt.Message);
}如果在trans.Commit();之前发生错误,或者return,那么连接会自动关闭,事务会不会自动回滚?
释放资源的代码:
private void Dispose(bool disposing)
{
if (disposing)
{
if (this.Connection != null)
{
this.Connection.Rollback();
}
this._connection = null;
}
}
所以在释放资源的时候,会回滚
10.0的时候才可以了