In the case of nesting, how does one deal with Castle. ActiveRecord transactions?
I tried it today. It turns out to be quite simple. Just use Castle. ActiveRecord. TransactionMode. Inherits.
Http://www.castleproject.org/activerecord/documentation/trunk/usersguide/scopes.html
Protected void btnInsert_Click (object sender, EventArgs e)
{
Insert (3 );
InsertOne ();
}
Private void InsertOne ()
{
TransactionScope scope = new TransactionScope (Castle. ActiveRecord. TransactionMode. Inherits );
Try
{
Blog blog = new Blog ();
Blog. Name = "blog1 ";
Blog. Author = "Author ";
Blog. Create ();
Insert (2 );
Int a = 0;
A = 100/;
Scope. VoteCommit ();
}
Catch
{
Scope. VoteRollBack ();
Throw;
}
Finally
{
Scope. Dispose ();
}
}
Private void Insert (int I)
{
TransactionScope scope = new TransactionScope (Castle. ActiveRecord. TransactionMode. Inherits );
Try
{
Blog blog = new Blog ();
Blog. Name = "blog" + I;
Blog. Author = "Author" + I;
Blog. Create ();
Scope. VoteCommit ();
}
Catch
{
Scope. VoteRollBack ();
Throw;
}
Finally
{
Scope. Dispose ();
}
}