Question about Transaction Handling

Question about Transaction Handling

Old forum URL: forums.lhotka.net/forums/t/747.aspx


Jason posted on Thursday, July 27, 2006

I am just starting with CSLA.Net 2.0 and have a basic business object built off of the EditableRoot template.  I'm using System.Transactions to handle any transactions.  I abstracted some of the data access code in DataPortal_Fetch into a separate project I am using to handle interaction with my database.  The data access code doesn't really do anything different than what is in the CSLA templates other than it is in a different project.  When my UI fetches a record using the standard CSLA template, everything works as expected.  When I change my business object to fetch from my new data access project, it begins a transaction.  I only noticed b/c implicit transactions were turned off on my DB so an exception was thrown.  I guess I don't understand why a transaction is enlisted in the second scenario, but not the first.

Here is my call to my data acess routines:

[Transactional(TransactionalTypes.TransactionScope)]

private void DataPortal_Fetch(Criteria criteria)

{

   using (SafeDataReader dr = CslaSqlHelper.ExecuteReader(Config.Database.ConnectionString,"getMyData",new object[] { criteria.Id }))

{

FetchObject(dr);

ValidationRules.CheckRules();

//load child object(s)

//FetchChildren(dr);

}

}

Any ideas?

 

Copyright (c) Marimer LLC