views:

180

answers:

1

Just a quick question about usage of TransactionScope in ActiveRecord. Is this something that is used and works or do people use some other method of handling transactions. I am not familiar, and I am not working with AC but I am thinking about adopting SessionScope and TransactionScope for my project, and was just wondering what people think about it.

+1  A: 

If you can use Windsor, I recommend using the ActiveRecordIntegration facility in combination with the Automatic Transaction Management Facility which allows you to apply transactions declaratively, e.g.:

using Castle.Services.Transaction;

[Transactional]
public class BusinessClass
{
    public void Load(int id)
    {
        ...
    }

    // note the "virtual" 
    [Transaction(TransactionMode.Requires)]
    public virtual void Save(Data data)
    {
        ...
    }
}
Mauricio Scheffer
No, I am not using Windsor, but was interested in their TransactionScope implementation. I was actually able to rip it out and use it in my project.
epitka