I'm trying to do the most simple thing and apply a transaction to the CreatePortal
method.
If I'm using TransactionScope
- It promotes to DTC for some unknown reason - BAD.
using (var ts = new TransactionScope())
{
var portalController = new PortalController();
var portalId =
portalController.CreatePortal(
"TESTTESTTEST",
string.Empty,
string.Empty,
"TESTTESTTEST_" + new Random().Next(999999),
UserController.GeneratePassword(),
"TESTTESTTEST_" + new Random().Next(999999) + "@something.com",
string.Empty,
string.Empty,
Globals.ApplicationMapPath + "/Portals/_default/",
"Default Website.template",
"Portals/TESTTEST",
"TESTTESTTEST",
string.Empty,
string.Empty,
false);
ts.Complete();
}
If I'm using DataProvider.Instance().GetTransaction
and performs RollbackTransaction
at the end - IT DOES NOT ROLLBACK, which means that the transaction didn't even work.
var t = Data.DataProvider.Instance().GetTransaction();
var portalController = new PortalController();
var portalId =
portalController.CreatePortal(
"TESTTESTTEST",
string.Empty,
string.Empty,
"TESTTESTTEST_" + new Random().Next(999999),
UserController.GeneratePassword(),
"TESTTESTTEST_" + new Random().Next(999999) + "@something.com",
string.Empty,
string.Empty,
Globals.ApplicationMapPath + "/Portals/_default/",
"Default Website.template",
"Portals/TESTTEST",
"TESTTESTTEST",
string.Empty,
string.Empty,
false);
Data.DataProvider.Instance().RollbackTransaction(t);
So, How to use transactions in DotNetNuke?