本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Update.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# Update.Cancel方法的具体用法?C# Update.Cancel怎么用?C# Update.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.Update
的用法示例。
在下文中一共展示了Update.Cancel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSaveThrowsExceptionWhenUpdateIsCancelled
public void TestSaveThrowsExceptionWhenUpdateIsCancelled()
{
var update = new Update(this.sesid, this.tableid, JET_prep.Insert);
update.Cancel();
update.Save();
}
示例2: TestCancelThrowsExceptionWhenUpdateIsDisposed
public void TestCancelThrowsExceptionWhenUpdateIsDisposed()
{
var update = new Update(this.sesid, this.tableid, JET_prep.Insert);
update.Dispose();
update.Cancel();
}
示例3: TestCancelUpdate
public void TestCancelUpdate()
{
Assert.IsFalse(Api.TryMoveFirst(this.sesid, this.tableid));
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
{
update.Cancel();
}
// the table should still be empty
Assert.IsFalse(Api.TryMoveFirst(this.sesid, this.tableid));
}
示例4: Update
//.........这里部分代码省略.........
using (var sr = new Table(session, dbid, item.table, OpenTableGrbit.None))
{
Api.JetCreateTable(session, dbid, newTable, 1, 80, out newTableId);
var existingColumns = Api.GetTableColumns(session, sr).ToList();
var existingIndexes = Api.GetTableIndexes(session, sr).ToList();
foreach (var column in existingColumns)
{
JET_COLUMNDEF columnDef = null;
Api.JetGetColumnInfo(session, dbid, item.table, column.Name, out columnDef);
JET_COLUMNID newColumndId;
if (column.Name == item.column)
{
Api.JetAddColumn(session, newTableId, item.column, new JET_COLUMNDEF
{
coltyp = JET_coltyp.Long,
grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
}, null, 0, out newColumndId);
}
else
{
var defaultValue = column.DefaultValue == null ? null : column.DefaultValue.ToArray();
var defaultValueLength = defaultValue == null ? 0 : defaultValue.Length;
{
Api.JetAddColumn(session, newTableId, column.Name, columnDef, defaultValue,
defaultValueLength, out newColumndId);
}
}
}
foreach (var index in existingIndexes)
{
var indexDesc = String.Join("\0", index.IndexSegments.Select(x => "+" + x.ColumnName)) +
"\0\0";
SchemaCreator.CreateIndexes(session, newTableId, new JET_INDEXCREATE()
{
szIndexName = index.Name,
szKey = indexDesc,
grbit = index.Grbit
});
}
var rows = 0;
using (var destTable = new Table(session, dbid, newTable, OpenTableGrbit.None))
{
Api.MoveBeforeFirst(session, sr);
Api.MoveBeforeFirst(session, destTable);
while (Api.TryMoveNext(session, sr))
{
using (var insert = new Update(session, destTable, JET_prep.Insert))
{
bool save = true;
foreach (var column in existingColumns)
{
var destcolumn = Api.GetTableColumnid(session, destTable, column.Name);
if (column.Name == item.column)
{
var viewName = Api.RetrieveColumnAsString(session, sr, column.Columnid,
Encoding.Unicode);
int value;
if (nameToIds.TryGetValue(viewName, out value) == false)
{
insert.Cancel();
save = false;
break;
}
Api.SetColumn(session, destTable, destcolumn, value);
}
else if ((column.Grbit & ColumndefGrbit.ColumnAutoincrement) == ColumndefGrbit.None)
{
var value = Api.RetrieveColumn(session, sr, column.Columnid);
Api.SetColumn(session, destTable, destcolumn, value);
}
}
if (save)
insert.Save();
}
if (rows++ % 10000 == 0)
{
output("Processed " + (rows) + " rows in " + item.table);
Api.JetCommitTransaction(session, CommitTransactionGrbit.LazyFlush);
Api.JetBeginTransaction2(session, BeginTransactionGrbit.None);
}
}
}
output("Processed " + (rows - 1) + " rows in " + item.table + ", and done with this table");
}
Api.JetCommitTransaction(session, CommitTransactionGrbit.None);
Api.JetDeleteTable(session, dbid, item.table);
Api.JetRenameTable(session, dbid, newTable, item.table);
Api.JetBeginTransaction2(session, BeginTransactionGrbit.None);
}
filesToDelete.ForEach(File.Delete);
UpdateLastIdentityForIndexes(session, dbid, maxIndexId + 1);
SchemaCreator.UpdateVersion(session, dbid, "5.0");
}