I am in the process of upgrading a data access component, built around daab 3, to the latest Enterprise Library 5. There seem to be fewer methods than the older version of the block. It had method signature that took in Connetion and Transactions objects.
In getting MARS to work, using transactions did not work as I did not have access to the values of output paramaters, of the first call, that was needed in the second call.
I got it to work by passing in a connection object to the different execute methods, and thus made use of MARS. But it is not clear how to do that now.
Can someone explain how to use MARS with the current DAAB 5.
Feb 24, 2011 at 12:58 AM
Edited Feb 24, 2011 at 2:03 AM
Walter, there's still an overload in DAAB in version 5.0 which allows you to pass a DbTransaction object. I assure you there is, you can even check the source code itself. As for passing a connection object, are you saying there's a distinct
parameter for it or you mean you can pass it by associating it to the transaction object which is the one which can actually be passed in the ExecuteNonQuery? Because I believe there's no overload in 3.1 which has a separate parameter for a connection
Anyway, you can make DAAB use a connection you want by creating and opening a connection and transaction prior to executing a command.
DbConnection connection = database.CreateConnection()
using(DbTransaction trans = connection.BeginTransaction())
//call executenonquery passing the trans object
trans.Commit(); //to commit all changes
The ExecuteNonQuery polls for an existing open connection and uses it if there's any.
Global Technologies and Solutions