title: Why doesn't AbortTransaction work?
body: <p>I am using npoco, trying to work with transactions, I can´t get the <code>AbortTransaction</code> method to rollback anything in my db.</p>
  
  <pre><code>public class ItemRepository
  {
    private Func&lt;Database&gt; _db;
  
    public ItemRepository(Func&lt;Database&gt; db)
    {
          _db = db;
    }
  
  Public void Update(){
      using (_db().Transaction)
      {
          _db().BeginTransaction();
          foreach (var item in itemToUpdate.Items)
          { 
              _db().Insert(item);
              if (SomethingIsNotCorrect())
              {
                  _db().AbortTransaction();
              }
          }
      _db().CompleteTransaction();
      }
  }}
  </code></pre>
  
  <p>Call from test class:</p>
  
  <pre><code>_db = () =&gt; new Database(String.Format("DataSource={0};Persist Security Info=False;", DbPath),"System.Data.SqlServerCe.4.0");
  _itemRepository = new ItemRepository(() =&gt; _db());
  _itemRepository.Update();
  </code></pre>
  
  <p>------------- edit after suggested answer:</p>
  
  <pre><code>var db = _db();
  using (db.Transaction)
  {
      db.BeginTransaction();  
      foreach (var item in itemToUpdate.Items)
      {
          db.Insert(item);
          db.Transaction.Commit();
          if (GetNutrientConns(itemToUpdate).Count &gt; 2)
          {
               db.AbortTransaction();
          }
      }  
      db.CompleteTransaction();
  }
  </code></pre>
  
  <p>Now I must use db.Transaction.Commit() to have something inserting in db. Then when trying to run db.AbortTransaction() I get error message:</p>
  
  <p>"This SqlCeTransaction has completed; it is no longer usable."</p>