TransactionScope and SQL2005

Topics: General Discussion Forum
Apr 18, 2007 at 11:40 AM
How is this code executed in sql, does it open two connections even if its the same connection string?
Is it better do do this in the stored procedure with joins or even sprocs called from sprocs than the solution below.

Im kinda new to this so be gentle. =)

using (TransactionScope ts = new TransactionScope)
Repository1 rep1 = new Repository1("Connection");
Entity[] ent = rep1.GetAll();
Repository2 rep2 = new Repository2("Connection");
Entity2[] ent2 = rep2.GetAll();
ent.Ent2List = new List<entity2>(ent2);




Apr 18, 2007 at 6:37 PM
Well, that's a design desition (SP vs DAL) that depends on your scenario and requirements.
Regarding the question about the two connections, the TransactionScope will enlist the conns in a DTC as stated in this thread Transactions.