Transaction spanning multiple business classes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a problem on how to span a transaction over multiple business classes
without using COM+

Example:
A existing person get an MailingAddress assigned to

public class PersonService
{
public void InsertMailingAddress(data)
{
//ask the AddressService to insert an address
new AddressService().InsertAddress();

//update the person with the ID from the newly inserted address
}
}

As you can see, this should be in a transaction --> Insert Address -->
Update Person
How can i span this in a transaction without passing sqltransaction objects
in the businesslayer?

Any ideas???
 
Hi Jakob

I know the patterns a little bit but i can't seem to get started

How would i implement this given the scenario i'm in?

Thanks for the help!!!
 
Implementing UnitOfWork and the related patterns (e.g. datamappers) is
probably not something you can do in a matter of minutes. I have tried
googling for some samples without any luck.

If you are in a hurry and do not have time to read through Fowler's book,
you might just opt for the easy solution and pass a reference to a
transaction object as a parameter. Another fairly easy solution is to
register a transaction object using some kind of Registry pattern and then
let the Insert and Update methods access the registry using a unique ID to
get a hold of the transaction. But the transaction would still have to
started by your business logic. Fowler also describes the Registry solution.

HTH, Jakob.
 
Back
Top