For Those interested.
My scenario is different from the example since I had to maintain
transaction through different adapters.
SO we just create new file and declare partial class. Make sure to have
correct namespace and class name.
Then I introduce following method
public void InitializeTransaction(SqlConnection connection, SqlTransaction
transaction)
{
_connection = connection;
this.Adapter.InsertCommand.Transaction = transaction;
Adapter.UpdateCommand.Transaction = transaction;
Adapter.DeleteCommand.Transaction = transaction;
foreach (SqlCommand command in CommandCollection)
{
if (command.CommandText.ToUpper().StartsWith("INSERT")) //this is for custom
queries. You mane need to have different checks here
{
command.Transaction = transaction;
}
}
}
That is it.
Now just create connection and transaction and pass it to addapter before
calling any dataaccess methods.