Exemple #1
0
        public IPenguinPersistenceContext StartTransaction()
        {
            if (transactionInfo != null)
            {
                throw new PersistenceException("Already in transaction.");
            }
            var session     = driver.Session();
            var transaction = session.BeginTransaction();
            var context     = new Neo4jPersistenceContext(transaction);

            transactionInfo = new TransactionInfo {
                Session = session, Transaction = transaction, Context = context
            };
            return(context);
        }
Exemple #2
0
 public void RunTransaction(Action <IPenguinPersistenceContext> contextAction)
 {
     if (this.transactionInfo == null)
     {
         using (var session = driver.Session())
         {
             session.WriteTransaction(tx =>
             {
                 var context = new Neo4jPersistenceContext(tx);
                 contextAction(context);
             });
         }
     }
     else
     {
         contextAction(this.transactionInfo.Context);
     }
 }