Note that there are some explanatory texts on larger screens.

plurals
  1. PORollback transaction in Repository from another class
    primarykey
    data
    text
    <p>well my problem is: I have a method like:</p> <pre><code>class Manager { void method1() { // save object in database to get ID int newId = this.Repository.Save(obj); try { // call remote webservice to save another object with same ID as in local DB webservice.Save(remoteObj, id); } catch(Exception e) { // do Rollback in Repository here } } } </code></pre> <p>Bassically this is the code. Repository use NHibernate to save to DB. I need to save in DB to know the new ID and then send this ID to webservice. If something fail calling webservice I want to rollback and discard saved object.... and here is my problem. I can't open and control a transaction in Repository from my class Manager.</p> <p>I already try with this also:</p> <pre><code>class Manager { void method1() { using (TransactionScope scope = new TransactionScope()) { // save object in database to get ID int newId = this.Repository.Save(obj); // call remote webservice to save another object with same ID // as in local DB webservice.Save(remoteObj, id); scope.Complete(); } } } </code></pre> <p>Here the problem is that the rollback is OK but not the Save(Create in NHibernate). I get error about that object "Transaction" is not found or the transaction is already closed just after the line : "scope.Complete();".</p> <p>I think that something is wrong trying to control NHibernate transaction with TransactionScope .</p> <p>I dont know if is a problem about approach, maybe another way should be used to handle this situation... ??</p> <p>any help or idea where to find ??</p> <p>Thanks a lot !!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload