当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.Dispose方法代码示例

本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Transaction.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.Dispose方法的具体用法?C# Transaction.Dispose怎么用?C# Transaction.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Isam.Esent.Interop.Transaction的用法示例。


在下文中一共展示了Transaction.Dispose方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WithDatabase

 public static void WithDatabase(this JET_INSTANCE instance, string database, Func<Session, JET_DBID, Transaction, Transaction> action)
 {
     using (var session = new Session(instance))
     {
         var tx = new Transaction(session);
         try
         {
             JET_DBID dbid;
             Api.JetOpenDatabase(session, database, "", out dbid, OpenDatabaseGrbit.None);
             try
             {
                 tx = action(session, dbid, tx);
             }
             finally
             {
                 Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
             }
             tx.Commit(CommitTransactionGrbit.None);
         }
         finally
         {
             if(tx != null)
                 tx.Dispose();
         }
     }
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:26,代码来源:EsentExtension.cs

示例2: Update

		public void Update(Session session, JET_DBID dbid)
		{
			Transaction tx;
			using (tx = new Transaction(session))
			{
				using ( var tbl = new Table(session, dbid, "indexes_stats",
					OpenTableGrbit.PermitDDL | OpenTableGrbit.DenyRead | OpenTableGrbit.DenyWrite))
				{
					var columnDictionary = Api.GetColumnDictionary(session, tbl);

					if (columnDictionary.ContainsKey("reduce_attempts"))
						Api.JetDeleteColumn(session, tbl, "reduce_attempts");
					if (columnDictionary.ContainsKey("reduce_errors"))
						Api.JetDeleteColumn(session, tbl, "reduce_errors");
					if (columnDictionary.ContainsKey("reduce_successes"))
						Api.JetDeleteColumn(session, tbl, "reduce_successes");
				}

				CreateIndexesStatsReduce(session, dbid);

				using (var stats = new Table(session, dbid, "indexes_stats",OpenTableGrbit.None))
				using (var reduce = new Table(session, dbid, "indexes_stats_reduce", OpenTableGrbit.None))
				{
					var tblKeyColumn = Api.GetColumnDictionary(session, stats)["key"];
					var reduceKeyCol = Api.GetColumnDictionary(session, reduce)["key"];

					Api.MoveBeforeFirst(session, stats);
					while (Api.TryMoveNext(session, stats))
					{
						using(var update = new Update(session, reduce, JET_prep.Insert))
						{
							var indexName = Api.RetrieveColumnAsString(session, stats, tblKeyColumn, Encoding.Unicode);
							Api.SetColumn(session, reduce, reduceKeyCol, indexName, Encoding.Unicode);
							update.Save();
						}
					}
				}

				tx.Commit(CommitTransactionGrbit.LazyFlush);
				tx.Dispose();
				tx = new Transaction(session);
			}

			using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
			{
				Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
				var columnids = Api.GetColumnDictionary(session, details);

				using (var update = new Update(session, details, JET_prep.Replace))
				{
					Api.SetColumn(session, details, columnids["schema_version"], "3.4", Encoding.Unicode);

					update.Save();
				}
			}
			tx.Commit(CommitTransactionGrbit.None);
			tx.Dispose();
		}
开发者ID:kblooie,项目名称:ravendb,代码行数:58,代码来源:From33To34.cs

示例3: Update

        public void Update(Session session, JET_DBID dbid)
        {
            Transaction tx;
            using (tx = new Transaction(session))
            {
                var count = 0;
                const int rowsInTxCount = 100;
                var tablesWithEtags = new[]
                {
                    new {Table = "indexes_stats", Column = "last_indexed_etag"},
                    new {Table = "documents", Column = "etag"},
                    new {Table = "mapped_results", Column = "etag"},
                    new {Table = "files", Column = "etag"},
                    new {Table = "documents_modified_by_transaction", Column = "etag"},
                };
                foreach (var tablesWithEtag in tablesWithEtags)
                {
                    using (var tbl = new Table(session, dbid, tablesWithEtag.Table, OpenTableGrbit.None))
                    {
                        var columnid = Api.GetColumnDictionary(session, tbl)[tablesWithEtag.Column];
                        Api.MoveBeforeFirst(session, tbl);
                        while (Api.TryMoveNext(session, tbl))
                        {
                            using (var update = new Update(session, tbl, JET_prep.Replace))
                            {
                                Api.SetColumn(session, tbl, columnid, Guid.Empty.TransformToValueForEsentSorting());
                                update.Save();
                            }
                            if (count++%rowsInTxCount == 0)
                            {
                                tx.Commit(CommitTransactionGrbit.LazyFlush);
                                tx.Dispose();
                                tx = new Transaction(session);
                            }
                        }
                        tx.Commit(CommitTransactionGrbit.LazyFlush);
                        tx.Dispose();
                        tx = new Transaction(session);
                    }
                }

                using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
                {
                    Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
                    var columnids = Api.GetColumnDictionary(session, details);

                    using (var update = new Update(session, details, JET_prep.Replace))
                    {
                        Api.SetColumn(session, details, columnids["schema_version"], "3.2", Encoding.Unicode);

                        update.Save();
                    }
                }
                tx.Commit(CommitTransactionGrbit.None);
                tx.Dispose();
            }
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:57,代码来源:From30To32.cs

示例4: DocumentStorageActions

		public DocumentStorageActions(
			JET_INSTANCE instance,
			string database,
			TableColumnsCache tableColumnsCache,
			OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
			IUuidGenerator uuidGenerator,
			IDocumentCacher cacher,
			EsentTransactionContext transactionContext,
			TransactionalStorage transactionalStorage)
		{
			this.tableColumnsCache = tableColumnsCache;
			this.documentCodecs = documentCodecs;
			this.uuidGenerator = uuidGenerator;
			this.cacher = cacher;
			this.transactionalStorage = transactionalStorage;
			this.transactionContext = transactionContext;

			try
			{
				if (transactionContext == null)
				{
					session = new Session(instance);
					transaction = new Transaction(session);
					sessionAndTransactionDisposer = () =>
					{
						if(transaction != null)
							transaction.Dispose();
						if(session != null)
							session.Dispose();
					};
				}
				else
				{
					session = transactionContext.Session;
					transaction = transactionContext.Transaction;
					var disposable = transactionContext.EnterSessionContext();
					sessionAndTransactionDisposer = disposable.Dispose;
				}
				Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
			}
			catch (Exception ex)
			{
			    logger.WarnException("Error when trying to open a new DocumentStorageActions", ex);
			    try
			    {
			        Dispose();
			    }
			    catch (Exception e)
			    {
			        logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
			    }
				throw;
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:54,代码来源:General.cs

示例5: Update

		public void Update(Session session, JET_DBID dbid)
		{
			Transaction tx;
			using (tx = new Transaction(session))
			{
				using (var tbl = new Table(session, dbid, "indexes_stats", OpenTableGrbit.PermitDDL | OpenTableGrbit.DenyRead|OpenTableGrbit.DenyWrite))
				{
					JET_COLUMNID columnid;
					var defaultValue = BitConverter.GetBytes(0);
					Api.JetAddColumn(session, tbl, "reduce_attempts", new JET_COLUMNDEF
					{
						coltyp = JET_coltyp.Long,
						grbit =
							ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnEscrowUpdate | ColumndefGrbit.ColumnNotNULL
					}, defaultValue, defaultValue.Length, out columnid);

					Api.JetAddColumn(session, tbl, "reduce_errors", new JET_COLUMNDEF
					{
						coltyp = JET_coltyp.Long,
						grbit =
							ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnEscrowUpdate | ColumndefGrbit.ColumnNotNULL
					}, defaultValue, defaultValue.Length, out columnid);

					Api.JetAddColumn(session, tbl, "reduce_successes", new JET_COLUMNDEF
					{
						coltyp = JET_coltyp.Long,
						grbit =
							ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnEscrowUpdate
					}, defaultValue, defaultValue.Length, out columnid);
				}
				tx.Commit(CommitTransactionGrbit.LazyFlush);
				tx.Dispose();
				tx = new Transaction(session);
			}

			using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
			{
				Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
				var columnids = Api.GetColumnDictionary(session, details);

				using (var update = new Update(session, details, JET_prep.Replace))
				{
					Api.SetColumn(session, details, columnids["schema_version"], "3.3", Encoding.Unicode);

					update.Save();
				}
			}
			tx.Commit(CommitTransactionGrbit.None);
			tx.Dispose();
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:50,代码来源:From32To33.cs

示例6: Update

		public void Update(Session session, JET_DBID dbid)
		{
			Transaction tx;
			using (tx = new Transaction(session))
			{
				CreateIndexingEtagsTable(dbid, session);

				using (var stats = new Table(session, dbid, "indexes_stats",OpenTableGrbit.None))
				using (var reduce = new Table(session, dbid, "indexes_etag", OpenTableGrbit.None))
				{
					var tblKeyColumn = Api.GetColumnDictionary(session, stats)["key"];
					var reduceKeyCol = Api.GetColumnDictionary(session, reduce)["key"];

					Api.MoveBeforeFirst(session, stats);
					while (Api.TryMoveNext(session, stats))
					{
						using(var update = new Update(session, reduce, JET_prep.Insert))
						{
							var indexName = Api.RetrieveColumnAsString(session, stats, tblKeyColumn, Encoding.Unicode);
							Api.SetColumn(session, reduce, reduceKeyCol, indexName, Encoding.Unicode);
							update.Save();
						}
					}
				}

				tx.Commit(CommitTransactionGrbit.LazyFlush);
				tx.Dispose();
				tx = new Transaction(session);
			}

			using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
			{
				Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
				var columnids = Api.GetColumnDictionary(session, details);

				using (var update = new Update(session, details, JET_prep.Replace))
				{
					Api.SetColumn(session, details, columnids["schema_version"], "3.6", Encoding.Unicode);

					update.Save();
				}
			}
			tx.Commit(CommitTransactionGrbit.None);
			tx.Dispose();
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:45,代码来源:From35To36.cs

示例7: Update

		public void Update(Session session, JET_DBID dbid)
		{
			Transaction tx;
			using (tx = new Transaction(session))
			{
				int count = 0;
				const int rowsInTxCount = 100;
				using (var files = new Table(session, dbid, "files", OpenTableGrbit.None))
				{
					var columnid = Api.GetColumnDictionary(session, files)["etag"];
					Api.MoveBeforeFirst(session, files);
					while (Api.TryMoveNext(session, files))
					{
						using (var update = new Update(session, files, JET_prep.Replace))
						{
							Api.SetColumn(session, files, columnid, DocumentDatabase.CreateSequentialUuid().TransformToValueForEsentSorting());
							update.Save();
						}
						if (count++ % rowsInTxCount == 0)
						{
							tx.Commit(CommitTransactionGrbit.LazyFlush);
							tx.Dispose();
							tx = new Transaction(session);
						}
					}
					tx.Commit(CommitTransactionGrbit.LazyFlush);
					tx.Dispose();
					tx = new Transaction(session);
				}

				using (var documents = new Table(session, dbid, "documents", OpenTableGrbit.None))
				{
					var columnid = Api.GetColumnDictionary(session, documents)["etag"];
					Api.MoveBeforeFirst(session, documents);
					while (Api.TryMoveNext(session, documents))
					{
						using (var update = new Update(session, documents, JET_prep.Replace))
						{
							Api.SetColumn(session, documents, columnid, DocumentDatabase.CreateSequentialUuid().TransformToValueForEsentSorting());
							update.Save();
						}
						if (count++ % rowsInTxCount == 0)
						{
							tx.Commit(CommitTransactionGrbit.LazyFlush);
							tx.Dispose();
							tx = new Transaction(session);
						}
					}
					tx.Commit(CommitTransactionGrbit.LazyFlush);
					tx.Dispose();
					tx = new Transaction(session);
				}

				using (var indexesStats = new Table(session, dbid, "indexes_stats", OpenTableGrbit.None))
				{
					var columnid = Api.GetColumnDictionary(session, indexesStats)["last_indexed_etag"];
					Api.MoveBeforeFirst(session, indexesStats);
					while (Api.TryMoveNext(session, indexesStats))
					{
						using (var update = new Update(session, indexesStats, JET_prep.Replace))
						{
							Api.SetColumn(session, indexesStats, columnid, Guid.Empty.TransformToValueForEsentSorting());
							update.Save();
						}
						if (count++ % rowsInTxCount == 0)
						{
							tx.Commit(CommitTransactionGrbit.LazyFlush);
							tx.Dispose();
							tx = new Transaction(session);
						}
					}
					tx.Commit(CommitTransactionGrbit.LazyFlush);
					tx.Dispose();
					tx = new Transaction(session);
				}

				using (var documentsModifiedByTransaction = new Table(session, dbid, "documents_modified_by_transaction", OpenTableGrbit.None))
				{
					var columnid = Api.GetColumnDictionary(session, documentsModifiedByTransaction)["etag"];
					Api.MoveBeforeFirst(session, documentsModifiedByTransaction);
					while (Api.TryMoveNext(session, documentsModifiedByTransaction))
					{
						using (var update = new Update(session, documentsModifiedByTransaction, JET_prep.Replace))
						{
							Api.SetColumn(session, documentsModifiedByTransaction, columnid, DocumentDatabase.CreateSequentialUuid().TransformToValueForEsentSorting());
							update.Save();
						}
						if (count++ % rowsInTxCount == 0)
						{
							tx.Commit(CommitTransactionGrbit.LazyFlush);
							tx.Dispose();
							tx = new Transaction(session);
						}
					}
					tx.Commit(CommitTransactionGrbit.LazyFlush);
					tx.Dispose();
					tx = new Transaction(session);

				}

//.........这里部分代码省略.........
开发者ID:ajaishankar,项目名称:ravendb,代码行数:101,代码来源:From28To29.cs

示例8: TestPropertyThrowsExceptionWhenDisposed

  public void TestPropertyThrowsExceptionWhenDisposed()
  {
      var transaction = new Transaction(this.sesid);
      transaction.Dispose();
      bool x = transaction.IsInTransaction;
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:6,代码来源:TransactionTests.cs

示例9: TestRollbackThrowsExceptionWhenDisposed

 public void TestRollbackThrowsExceptionWhenDisposed()
 {
     var transaction = new Transaction(this.sesid);
     transaction.Dispose();
     transaction.Rollback();
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:6,代码来源:TransactionTests.cs

示例10: TestCommitThrowsExceptionWhenDisposed

 public void TestCommitThrowsExceptionWhenDisposed()
 {
     var transaction = new Transaction(this.sesid);
     transaction.Dispose();
     transaction.Commit(CommitTransactionGrbit.None);
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:6,代码来源:TransactionTests.cs

示例11: TestBeginThrowsExceptionWhenDisposed

 public void TestBeginThrowsExceptionWhenDisposed()
 {
     var transaction = new Transaction(this.sesid);
     transaction.Dispose();
     transaction.Begin();
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:6,代码来源:TransactionTests.cs

示例12: ReAddAllLogsToIndex

 public long ReAddAllLogsToIndex(JET_SESID session, IndexTableSchema idxSchema)
 {
     var ret = 0L;
     Transaction tran = new Transaction(session);
     try
     {
         var tranCount = 0;
         Api.MoveBeforeFirst(session, logTable);
         while (Api.TryMoveNext(session, logTable))
         {
             var curLogId = (long)Api.RetrieveColumnAsInt64(session, logTable, colID_ID);
             idxSchema.InsertIndexRow(session, tran, curLogId);
             tranCount++;
             ret++;
             if (tranCount >= 50)
             {
                 tran.Commit(CommitTransactionGrbit.LazyFlush);
                 tran.Dispose();
                 tran = new Transaction(session);
             }
         }
         tran.Commit(CommitTransactionGrbit.LazyFlush);
     }
     finally
     {
         tran.Dispose();
     }
     return ret;
 }
开发者ID:simonkang,项目名称:NAppProfiler,代码行数:29,代码来源:LogTableSchema.cs

示例13: Update

		public void Update(Session session, JET_DBID dbid)
		{
			Transaction tx;
			using (tx = new Transaction(session))
			{
                using (var tbl = new Table(session, dbid, "indexes_stats_reduce",
					OpenTableGrbit.PermitDDL | OpenTableGrbit.DenyRead | OpenTableGrbit.DenyWrite))
				{
				    JET_COLUMNID columnid;
				    Api.JetAddColumn(session, tbl, "last_reduced_etag", new JET_COLUMNDEF
                    {
                        coltyp = JET_coltyp.Binary,
                        cbMax = 16,
                        grbit = ColumndefGrbit.ColumnFixed
                    }, null, 0, out columnid);


                    Api.JetAddColumn(session, tbl, "last_reduced_timestamp", new JET_COLUMNDEF
                    {
                        coltyp = JET_coltyp.DateTime,
                        grbit = ColumndefGrbit.ColumnFixed
                    }, null, 0, out columnid);
				}

				tx.Commit(CommitTransactionGrbit.LazyFlush);
				tx.Dispose();
				tx = new Transaction(session);
			}

            using (var tbl = new Table(session, dbid, "mapped_results",
                    OpenTableGrbit.PermitDDL | OpenTableGrbit.DenyRead | OpenTableGrbit.DenyWrite))
            {
                JET_COLUMNID columnid;
                Api.JetAddColumn(session, tbl, "timestamp", new JET_COLUMNDEF
                {
                    coltyp = JET_coltyp.DateTime,
                    grbit = ColumndefGrbit.ColumnFixed
                }, null, 0, out columnid);
                const string indexDef = "+view\0-etag\0\0";
                Api.JetCreateIndex(session, tbl, "by_view_and_etag", CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length,
                                   100);

            }

            using (var mappedResults = new Table(session, dbid, "mapped_results", OpenTableGrbit.None))
            {
                var tblKeyColumn = Api.GetColumnDictionary(session, mappedResults);

                Api.MoveBeforeFirst(session, mappedResults);
                while (Api.TryMoveNext(session, mappedResults))
                {
                    using (var update = new Update(session, mappedResults, JET_prep.Replace))
                    {
                        Api.SetColumn(session, mappedResults, tblKeyColumn["timestamp"], DateTime.Now);
                        update.Save();
                    }
                }
            }

			using (var details = new Table(session, dbid, "details", OpenTableGrbit.None))
			{
				Api.JetMove(session, details, JET_Move.First, MoveGrbit.None);
				var columnids = Api.GetColumnDictionary(session, details);

				using (var update = new Update(session, details, JET_prep.Replace))
				{
					Api.SetColumn(session, details, columnids["schema_version"], "3.5", Encoding.Unicode);

					update.Save();
				}
			}
			tx.Commit(CommitTransactionGrbit.None);
			tx.Dispose();
		}
开发者ID:kblooie,项目名称:ravendb,代码行数:74,代码来源:From34To35.cs


注:本文中的Microsoft.Isam.Esent.Interop.Transaction.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。