Trying to work out whether TransactionScope would be useful to us.
Normally, our DataAccessAdapters are wrapped with a Using statement. If I understand correctly then DataAccessAdapter would recognize whether if is in a TransactionScope and talk to it instead of creating its own database transaction.
What I'm not clear about is how connections work in this case and if/how connections are shared.
Ideally, we want each method on a server-side service object to be able to work without having to pass adapters around. However if one method calls another and both have created their own DataAccessAdapter then two connections are made and the DTC kicks in. This knackers us completely since our workstations/servers don't have the correct ports open so this is a no-go.
We are playing with a solution whereby we wrap our code like
using(new Session()) {
///
}
Session has a DataAccessAdapter property which lazy-instantiates an instance and stores it in ThreadLocalStorage. This way, within any Session using block, we will always get the same Adapter.
Personally I don't like this and would rather split the methods into two - one method (defined on the service interface) that creates an Adapter and passes it to another internal method and to actually do the work using the passed in adapter. The internal method can then be called from one or more public methods.
What do other folks do on the server service side?
Cheers
Simon