AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 shouldn't a SQL rollback be in the catch {}
Rank: Member
Groups: Developers, Registered, HelpDesk Joined: 11/7/2018(UTC) Posts: 23
Thanks: 5 times
|
In the code below, a SQL transaction is initiated inside the try/catch. If an exception is thrown, the SQL transaction never gets told to roll back. Shouldn't the catch be doing a SQL rollback? This is the /Areas/Admin/Controllers/HelpController.cs Code:
public ActionResult DeleteSelected(FormCollection form)
{
List<int> errorIds = new List<int>();
if (form.Keys.Count > 0)
{
try
{
var selectedKeys = form.AllKeys.Where(key => key.ToUpper().StartsWith("ERROR_CHK_",
StringComparison.InvariantCultureIgnoreCase)).Where(x => form[x].Contains("true")).ToList();
foreach (var key in selectedKeys)
{
errorIds.Add(AlwaysConvert.ToInt(key.Substring(10)));
}
IDatabaseSessionManager database = AbleContext.Current.Database;
database.BeginTransaction();
foreach (int cid in errorIds)
{
var error = _errorMessageRepo.Load(cid);
_errorMessageRepo.Delete(error);
}
database.CommitTransaction();
}
catch (Exception exp)
{
Logger.Error(exp.Message, exp);
}
}
return ErrorLogList();
}
|
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 shouldn't a SQL rollback be in the catch {}
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close