If I am using attribute based transaction in Spring.Net, something looks like
[Transaction()]
public void MyBusinessMethod()
{
// doing some in memory calculation, may take some time
Prepare();
// actual db access code
DbAccess();
}
In the method, Prepare() will do some preparation work without involving the database layer. For optimum performance, the db connection should be opened just before DbAccess(). However, since I am using AOP to do transaction and it applies at method level, does it means that the connection will be opened when the method MyBusinessMehtod is called? If it is, is there any way to improve that? One way I can think of is to factor the DbAccess out to its own method. Besides that, any other good recommendations?