本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Transaction.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.Commit方法的具体用法?C# Transaction.Commit怎么用?C# Transaction.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.Transaction
的用法示例。
在下文中一共展示了Transaction.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create(string database)
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, null, out dbid, CreateDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
CreateDetailsTable(dbid);
CreateDocumentsTable(dbid);
CreateTasksTable(dbid);
CreateScheduledReductionsTable(dbid);
CreateMapResultsTable(dbid);
CreateReduceResultsTable(dbid);
CreateIndexingStatsTable(dbid);
CreateIndexingStatsReduceTable(dbid);
CreateIndexingEtagsTable(dbid);
CreateFilesTable(dbid);
CreateQueueTable(dbid);
CreateListsTable(dbid);
CreateIdentityTable(dbid);
CreateReduceKeysCountsTable(dbid);
CreateReduceKeysStatusTable(dbid);
CreateIndexedDocumentsReferencesTable(dbid);
tx.Commit(CommitTransactionGrbit.None);
}
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}
示例2: Create
public void Create(JET_SESID session, JET_DBID dbid)
{
using (var tran = new Transaction(session))
{
JET_TABLEID tblID;
Api.JetCreateTable(session, dbid, tableName, 1, 80, out tblID);
JET_COLUMNID c;
Api.JetAddColumn(session, tblID, colName_ID, new JET_COLUMNDEF()
{
coltyp = JET_coltyp.Currency,
grbit = ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL,
}, null, 0, out c);
Api.JetAddColumn(session, tblID, colName_LogID, new JET_COLUMNDEF()
{
coltyp = JET_coltyp.Currency,
grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL,
}, null, 0, out c);
var indexDef = "+" + colName_ID + "\0\0";
Api.JetCreateIndex(session, tblID, idxName_Primary, CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 80);
tran.Commit(CommitTransactionGrbit.None);
}
}
示例3: CreateTable
internal static void CreateTable(Session session, JET_DBID dbid)
{
JET_TABLEID tableid;
Api.JetCreateTable(session, dbid, ifcHeaderTableName, 1, 100, out tableid);
using (var transaction = new Microsoft.Isam.Esent.Interop.Transaction(session))
{
JET_COLUMNID columnid;
var columndef = new JET_COLUMNDEF
{
coltyp = JET_coltyp.Long,
grbit = ColumndefGrbit.ColumnAutoincrement
};
Api.JetAddColumn(session, tableid, _colNameHeaderId, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Currency;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(session, tableid, _colNameEntityCount, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.LongBinary;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(session, tableid, _colNameHeaderData, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Text;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
columndef.cbMax = 32;
Api.JetAddColumn(session, tableid, _colNameFileVersion, columndef, null, 0, out columnid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
示例4: Update
public void Update(Session session, JET_DBID dbid)
{
using (var tx = new Transaction(session))
{
using (var tasks = new Table(session, dbid, "tasks", OpenTableGrbit.None))
{
JET_COLUMNID columnid;
Api.JetAddColumn(session, tasks, "added_at",new JET_COLUMNDEF
{
coltyp = JET_coltyp.DateTime,
grbit = ColumndefGrbit.ColumnNotNULL
}, null, 0, out columnid);
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"], "2.5", Encoding.Unicode);
update.Save();
}
}
}
tx.Commit(CommitTransactionGrbit.None);
}
}
示例5: Create
public void Create(string database)
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, null, out dbid, CreateDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
CreateDetailsTable(dbid);
CreateDocumentsTable(dbid);
CreateDocumentsBeingModifiedByTransactionsTable(dbid);
CreateTransactionsTable(dbid);
CreateTasksTable(dbid);
CreateMapResultsTable(dbid);
CreateIndexingStatsTable(dbid);
CreateIndexingStatsReduceTable(dbid);
CreateFilesTable(dbid);
CreateQueueTable(dbid);
CreateIdentityTable(dbid);
tx.Commit(CommitTransactionGrbit.None);
}
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}
示例6: Create
public void Create(string database)
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, null, out dbid, CreateDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
CreateDetailsTable(dbid);
CreateQueuesTable(dbid);
CreateSubQueuesTable(dbid);
CreateTransactionTable(dbid);
CreateRecoveryTable(dbid);
CreateOutgoingTable(dbid);
CreateOutgoingHistoryTable(dbid);
CreateReceivedMessagesTable(dbid);
tx.Commit(CommitTransactionGrbit.None);
}
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}
示例7: Update
public void Update(Session session, JET_DBID dbid)
{
using (var tx = new Transaction(session))
{
using (var files = new Table(session, dbid, "files", OpenTableGrbit.None))
{
const string indexDef = "+etag\0\0";
Api.JetCreateIndex(session, files, "by_etag", CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length,
100);
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"], "2.7", Encoding.Unicode);
update.Save();
}
}
}
tx.Commit(CommitTransactionGrbit.None);
}
}
示例8: CreateDatabase
private static void CreateDatabase()
{
using (var databaseInstance = new Instance(DatabasePath))
{
InitializeDatabaseInstance(databaseInstance);
if (File.Exists(DatabasePath))
{
return;
}
using (var session = new Session(databaseInstance))
{
JET_DBID dbid;
Api.JetCreateDatabase(session, DatabasePath, null, out dbid, CreateDatabaseGrbit.OverwriteExisting);
using (var transaction = new Transaction(session))
{
JET_TABLEID tableid;
Api.JetCreateTable(session, dbid, "Message", 0, 100, out tableid);
CreateIdColumn(session, tableid);
CreateDateCreatedColumn(session, tableid);
CreateIndexes(session, tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
Api.JetDetachDatabase(session, DatabasePath);
}
}
}
示例9: GetUniqueId
public int GetUniqueId(string value)
{
OpenTableForUpdatingWithoutTransaction();
while (true)
{
if (TrySeek(value))
{
return Api.RetrieveColumnAsInt32(SessionId, TableId, _idColumnId).Value;
}
using (var transaction = new Transaction(SessionId))
{
PrepareUpdate(JET_prep.Insert);
var id = Api.RetrieveColumnAsInt32(SessionId, TableId, _idColumnId, RetrieveColumnGrbit.RetrieveCopy).Value;
// set name
Api.SetColumn(SessionId, TableId, _nameColumnId, value, Encoding.Unicode);
if (ApplyChanges())
{
transaction.Commit(CommitTransactionGrbit.LazyFlush);
return id;
}
}
}
}
示例10: 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();
}
}
}
示例11: CreateBasicTableColumnIndex3OnXp
public void CreateBasicTableColumnIndex3OnXp()
{
var tablecreate = new JET_TABLECREATE { szTableName = "table" };
string directory = SetupHelper.CreateRandomDirectory();
string database = Path.Combine(directory, "test.db");
using (var instance = new Instance("XpCreateBasicTableColumnIndex3"))
{
instance.Parameters.Recovery = false;
instance.Parameters.NoInformationEvent = true;
instance.Parameters.MaxTemporaryTables = 0;
instance.Init();
using (var session = new Session(instance))
{
JET_DBID dbid;
Api.JetCreateDatabase(session, database, String.Empty, out dbid, CreateDatabaseGrbit.None);
using (var transaction = new Transaction(session))
{
Api.JetCreateTableColumnIndex3(session, dbid, tablecreate);
Assert.AreNotEqual(JET_TABLEID.Nil, tablecreate.tableid);
Assert.AreEqual(tablecreate.cCreated, 1);
Api.JetCloseTable(session, tablecreate.tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
}
}
示例12: Update
public void Update(Session session, JET_DBID dbid)
{
using(var tx = new Transaction(session))
{
using (var mappedResults = new Table(session, dbid, "mapped_results", OpenTableGrbit.None))
{
JET_COLUMNID columnid;
Api.JetAddColumn(session, mappedResults, "reduce_key_and_view_hashed", new JET_COLUMNDEF
{
cbMax = 32,
coltyp = JET_coltyp.Binary,
grbit = ColumndefGrbit.ColumnNotNULL
}, null, 0, out columnid);
const string indexDef = "+reduce_key_and_view_hashed\0\0";
Api.JetCreateIndex(session, mappedResults, "by_reduce_key_and_view_hashed",
CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length,
100);
Api.JetDeleteIndex(session, mappedResults, "by_view_and_reduce_key");
var columnDictionary = Api.GetColumnDictionary(session, mappedResults);
Api.MoveBeforeFirst(session, mappedResults);
while (Api.TryMoveNext(session, mappedResults))
{
using (var update = new Update(session, mappedResults, JET_prep.Replace))
{
var computeHash = MapReduceIndex.ComputeHash(
Api.RetrieveColumnAsString(session, mappedResults, columnDictionary["view"],
Encoding.Unicode),
Api.RetrieveColumnAsString(session, mappedResults, columnDictionary["reduce_key"],
Encoding.Unicode));
Api.SetColumn(session, mappedResults, columnDictionary["reduce_key_and_view_hashed"],
computeHash);
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"], "2.2", Encoding.Unicode);
update.Save();
}
}
}
tx.Commit(CommitTransactionGrbit.None);
}
}
示例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",
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();
}
示例14: JetRetrieveColumns
public void JetRetrieveColumns()
{
short s = Any.Int16;
string str = Any.String;
double d = Any.Double;
var setcolumns = new[]
{
new JET_SETCOLUMN { cbData = sizeof(short), columnid = this.columnDict["Int16"], pvData = BitConverter.GetBytes(s) },
new JET_SETCOLUMN { cbData = sizeof(double), columnid = this.columnDict["Double"], pvData = BitConverter.GetBytes(d) },
new JET_SETCOLUMN { cbData = str.Length * sizeof(char), columnid = this.columnDict["Unicode"], pvData = Encoding.Unicode.GetBytes(str) },
new JET_SETCOLUMN { cbData = 0, columnid = this.columnDict["Binary"], pvData = null },
};
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.JetSetColumns(this.session, this.tableid, setcolumns, setcolumns.Length);
update.Save();
trx.Commit(CommitTransactionGrbit.None);
}
Api.TryMoveFirst(this.session, this.tableid);
var retrievecolumns = new[]
{
new JET_RETRIEVECOLUMN { cbData = sizeof(short), columnid = this.columnDict["Int16"], pvData = new byte[sizeof(short)] },
new JET_RETRIEVECOLUMN { cbData = sizeof(double), columnid = this.columnDict["Double"], pvData = new byte[sizeof(double)] },
new JET_RETRIEVECOLUMN { cbData = str.Length * sizeof(char) * 2, columnid = this.columnDict["Unicode"], pvData = new byte[str.Length * sizeof(char) * 2] },
new JET_RETRIEVECOLUMN { cbData = 10, columnid = this.columnDict["Binary"], pvData = new byte[10] },
};
for (int i = 0; i < retrievecolumns.Length; ++i)
{
retrievecolumns[i].itagSequence = 1;
}
Api.JetRetrieveColumns(this.session, this.tableid, retrievecolumns, retrievecolumns.Length);
// retrievecolumns[0] = short
Assert.AreEqual(sizeof(short), retrievecolumns[0].cbActual);
Assert.AreEqual(JET_wrn.Success, retrievecolumns[0].err);
Assert.AreEqual(s, BitConverter.ToInt16(retrievecolumns[0].pvData, 0));
// retrievecolumns[1] = double
Assert.AreEqual(sizeof(double), retrievecolumns[1].cbActual);
Assert.AreEqual(JET_wrn.Success, retrievecolumns[1].err);
Assert.AreEqual(d, BitConverter.ToDouble(retrievecolumns[1].pvData, 0));
// retrievecolumns[2] = string
Assert.AreEqual(str.Length * sizeof(char), retrievecolumns[2].cbActual);
Assert.AreEqual(JET_wrn.Success, retrievecolumns[2].err);
Assert.AreEqual(str, Encoding.Unicode.GetString(retrievecolumns[2].pvData, 0, retrievecolumns[2].cbActual));
// retrievecolumns[3] = null
Assert.AreEqual(0, retrievecolumns[3].cbActual);
Assert.AreEqual(JET_wrn.ColumnNull, retrievecolumns[3].err);
}
示例15: 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();
}
}