CodeConfig equivalent for tx: with attribute

I use CodeConfig as opposed to XML files for Spring.NET, using Fluent NHibernate to read / write to the database.

But for transaction management, I still want to use the Spring [Transaction] attribute for my maintenance methods. In XML, I would do

<tx:attribute-driven/> 

I can get around this by processing a transaction like this

 public WorkItem SaveWorkItem(WorkItem workItem) { using (ITransaction tx = CurrentSession.BeginTransaction()) { CurrentSession.SaveOrUpdate(workItem); tx.Commit(); } return workItem; } 

But is there only a CodeConfig way to use this attribute, for example:

 [Transaction] public WorkItem SaveWorkItem(WorkItem workItem) { CurrentSession.SaveOrUpdate(workItem); return workItem; } 

thanks

+4
source share
1 answer
0
source

All Articles