本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Update.SaveAndGotoBookmark方法的典型用法代码示例。如果您正苦于以下问题:C# Update.SaveAndGotoBookmark方法的具体用法?C# Update.SaveAndGotoBookmark怎么用?C# Update.SaveAndGotoBookmark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.Update
的用法示例。
在下文中一共展示了Update.SaveAndGotoBookmark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteOnReduceKey
private void ExecuteOnReduceKey(string view, string reduceKey,
Table table,
IDictionary<string, JET_COLUMNID> columnids,
Action updateAction,
Action insertAction)
{
var hashReduceKey = HashReduceKey(reduceKey);
Api.JetSetCurrentIndex(session, table, "by_view_and_hashed_reduce_key");
Api.MakeKey(session, table, view, Encoding.Unicode, MakeKeyGrbit.NewKey);
Api.MakeKey(session, table, hashReduceKey, MakeKeyGrbit.None);
Api.MakeKey(session, table, reduceKey, Encoding.Unicode, MakeKeyGrbit.None);
if (Api.TrySeek(session, table, SeekGrbit.SeekEQ) == false)
{
if (insertAction == null)
return;
using (var update = new Update(session, table, JET_prep.Insert))
{
Api.SetColumn(session, table, columnids["view"], view, Encoding.Unicode);
Api.SetColumn(session, table, columnids["reduce_key"], reduceKey, Encoding.Unicode);
Api.SetColumn(session, table, columnids["hashed_reduce_key"], hashReduceKey);
insertAction();
update.SaveAndGotoBookmark();
}
return;
}
Api.MakeKey(session, table, view, Encoding.Unicode, MakeKeyGrbit.NewKey);
Api.MakeKey(session, table, hashReduceKey, MakeKeyGrbit.None);
Api.MakeKey(session, table, reduceKey, Encoding.Unicode, MakeKeyGrbit.None);
Api.TrySetIndexRange(session, table, SetIndexRangeGrbit.RangeInclusive | SetIndexRangeGrbit.RangeUpperLimit);
do
{
var reduceKeyFromDb = Api.RetrieveColumnAsString(session, table, columnids["reduce_key"]);
if (StringComparer.Ordinal.Equals(reduceKey, reduceKeyFromDb) == false)
continue;
updateAction();
return;
} while (Api.TryMoveNext(session, table));
// couldn't find it...
if (insertAction == null)
return;
using (var update = new Update(session, table, JET_prep.Insert))
{
Api.SetColumn(session, table, columnids["view"], view, Encoding.Unicode);
Api.SetColumn(session, table, columnids["reduce_key"], reduceKey, Encoding.Unicode);
Api.SetColumn(session, table, columnids["hashed_reduce_key"], hashReduceKey);
insertAction();
update.SaveAndGotoBookmark();
}
}
示例2: TestSaveAndGotoBookmarkThrowsExceptionWhenUpdateIsDisposed
public void TestSaveAndGotoBookmarkThrowsExceptionWhenUpdateIsDisposed()
{
var update = new Update(this.sesid, this.tableid, JET_prep.Insert);
update.Dispose();
update.SaveAndGotoBookmark();
}
示例3: GenerateSomeLogs
/// <summary>
/// Generate some logs. This is used by tests that do backups.
/// </summary>
/// <param name="sesid">The session to use.</param>
/// <param name="dbid">The database to use to generate the logs.</param>
private static void GenerateSomeLogs(JET_SESID sesid, JET_DBID dbid)
{
if (EsentVersion.SupportsWindows7Features)
{
for (int i = 0; i < 10; ++i)
{
Api.JetCommitTransaction(sesid, Windows7Grbits.ForceNewLog);
}
}
else
{
using (var transaction = new Transaction(sesid))
{
JET_TABLEID junkTable;
Api.JetCreateTable(sesid, dbid, "junk", 1, 100, out junkTable);
JET_COLUMNID binaryColumn;
Api.JetAddColumn(sesid, junkTable, "column", new JET_COLUMNDEF { coltyp = JET_coltyp.LongBinary }, null, 0, out binaryColumn);
byte[] data = new byte[1023];
for (int i = 0; i < 256; ++i)
{
using (var update = new Update(sesid, junkTable, JET_prep.Insert))
{
Api.JetSetColumn(
sesid,
junkTable,
binaryColumn,
data,
data.Length,
SetColumnGrbit.IntrinsicLV,
null);
update.SaveAndGotoBookmark();
}
transaction.Commit(CommitTransactionGrbit.LazyFlush);
transaction.Begin();
}
Api.JetCloseTable(sesid, junkTable);
Api.JetDeleteTable(sesid, dbid, "junk");
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
}
示例4: InsertRecord
/// <summary>
/// Insert a record with the given column values. After the insert the cursor is
/// positioned on the record.
/// </summary>
/// <param name="key">
/// The key of the record.
/// </param>
/// <param name="values">
/// The column values to insert.
/// </param>
private void InsertRecord(int key, params string[] values)
{
using (var transaction = new Transaction(this.sesid))
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.sesid, this.tableid, this.keyColumn, key);
foreach (string value in values)
{
var setinfo = new JET_SETINFO
{
ibLongValue = 0,
itagSequence = 0,
};
byte[] data = Encoding.Unicode.GetBytes(value);
Api.JetSetColumn(
this.sesid, this.tableid, this.multiValueColumn, data, data.Length, SetColumnGrbit.None, setinfo);
}
update.SaveAndGotoBookmark();
transaction.Commit(CommitTransactionGrbit.None);
}
}
示例5: TestSaveAndGotoBookmarkPositionsCursor
public void TestSaveAndGotoBookmarkPositionsCursor()
{
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
{
update.SaveAndGotoBookmark();
}
Api.RetrieveKey(this.sesid, this.tableid, RetrieveKeyGrbit.None);
}
示例6: RetrieveColumnsWithZeroLength
public void RetrieveColumnsWithZeroLength()
{
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.session, this.tableid, this.columnDict["Unicode"], String.Empty, Encoding.Unicode);
Api.SetColumn(this.session, this.tableid, this.columnDict["Binary"], new byte[0]);
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new StringColumnValue { Columnid = this.columnDict["Unicode"] },
new BytesColumnValue { Columnid = this.columnDict["Binary"] },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
Assert.AreEqual(String.Empty, columnValues[0].ValueAsObject);
CollectionAssert.AreEqual(new byte[0], columnValues[1].ValueAsObject as byte[]);
}
示例7: GetRecordSizeOnVista
public void GetRecordSizeOnVista()
{
if (!EsentVersion.SupportsVistaFeatures)
{
return;
}
string directory = SetupHelper.CreateRandomDirectory();
string database = Path.Combine(directory, "test.db");
using (var instance = new Instance("VistaGetRecordSize"))
{
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))
{
JET_TABLEID tableid;
Api.JetCreateTable(session, dbid, "table", 0, 100, out tableid);
JET_COLUMNID columnid;
Api.JetAddColumn(
session,
tableid,
"column1",
new JET_COLUMNDEF { coltyp = JET_coltyp.LongBinary },
null,
0,
out columnid);
var size = new JET_RECSIZE();
byte[] data = Any.Bytes;
using (var update = new Update(session, tableid, JET_prep.Insert))
{
Api.SetColumn(session, tableid, columnid, data);
VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.Local | GetRecordSizeGrbit.InCopyBuffer);
update.SaveAndGotoBookmark();
}
VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.RunningTotal);
Assert.AreEqual(data.Length * 2, size.cbData, "cbData");
Assert.AreEqual(data.Length * 2, size.cbDataCompressed, "cbDataCompressed");
Assert.AreEqual(0, size.cbLongValueData, "cbLongValueData");
Assert.AreEqual(0, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
Assert.AreEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
Assert.AreEqual(0, size.cLongValues, "cLongValues");
Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
Assert.AreEqual(2, size.cTaggedColumns, "cTaggedColumns");
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
}
Cleanup.DeleteDirectoryWithRetry(directory);
}
示例8: RetrieveColumnsWithMultivalues
public void RetrieveColumnsWithMultivalues()
{
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.JetSetColumn(
this.session,
this.tableid,
this.columnDict["uint64"],
BitConverter.GetBytes(5UL),
sizeof(ulong),
SetColumnGrbit.None,
new JET_SETINFO { itagSequence = 1 });
Api.JetSetColumn(
this.session,
this.tableid,
this.columnDict["uint64"],
BitConverter.GetBytes(99UL),
sizeof(ulong),
SetColumnGrbit.None,
new JET_SETINFO { itagSequence = 2 });
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new UInt64ColumnValue { Columnid = this.columnDict["UInt64"], ItagSequence = 1 },
new UInt64ColumnValue { Columnid = this.columnDict["UInt64"], ItagSequence = 2 },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
Assert.AreEqual(5UL, columnValues[0].ValueAsObject);
Assert.AreEqual(99UL, columnValues[1].ValueAsObject);
}
示例9: RetrieveColumnsWithNull
public void RetrieveColumnsWithNull()
{
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new BoolColumnValue { Columnid = this.columnDict["Boolean"] },
new ByteColumnValue { Columnid = this.columnDict["Byte"] },
new Int16ColumnValue { Columnid = this.columnDict["Int16"] },
new UInt16ColumnValue { Columnid = this.columnDict["UInt16"] },
new Int32ColumnValue { Columnid = this.columnDict["Int32"] },
new UInt32ColumnValue { Columnid = this.columnDict["UInt32"] },
new Int64ColumnValue { Columnid = this.columnDict["Int64"] },
new UInt64ColumnValue { Columnid = this.columnDict["UInt64"] },
new FloatColumnValue { Columnid = this.columnDict["Float"] },
new DoubleColumnValue { Columnid = this.columnDict["Double"] },
new DateTimeColumnValue { Columnid = this.columnDict["DateTime"] },
new GuidColumnValue { Columnid = this.columnDict["Guid"] },
new StringColumnValue { Columnid = this.columnDict["Unicode"] },
new BytesColumnValue { Columnid = this.columnDict["Binary"] },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
foreach (var c in columnValues)
{
Assert.IsNull(c.ValueAsObject);
}
}
示例10: RetrieveColumnsWithInvalidColumn
public void RetrieveColumnsWithInvalidColumn()
{
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.session, this.tableid, this.columnDict["Int64"], Any.Int64);
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new GuidColumnValue { Columnid = this.columnDict["Int64"] },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
}
示例11: RetrieveColumnsWithLargeValues
public void RetrieveColumnsWithLargeValues()
{
string str = Any.StringOfLength(129 * 1024);
byte[] bytes = Any.BytesOfLength(127 * 1024);
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.session, this.tableid, this.columnDict["Unicode"], str, Encoding.Unicode);
Api.SetColumn(this.session, this.tableid, this.columnDict["Binary"], bytes);
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new StringColumnValue { Columnid = this.columnDict["Unicode"] },
new BytesColumnValue { Columnid = this.columnDict["Binary"] },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
Assert.AreEqual(str, columnValues[0].ValueAsObject);
CollectionAssert.AreEqual(bytes, columnValues[1].ValueAsObject as byte[]);
}
示例12: RetrieveColumns
public void RetrieveColumns()
{
bool bit = Any.Boolean;
byte b = Any.Byte;
short i16 = Any.Int16;
ushort ui16 = Any.UInt16;
int i32 = Any.Int32;
uint ui32 = Any.UInt32;
long i64 = Any.Int64;
ulong ui64 = Any.UInt64;
float f = Any.Float;
double d = Any.Double;
DateTime date = Any.DateTime;
Guid guid = Any.Guid;
string str = Any.String;
byte[] bytes = Any.BytesOfLength(1023);
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.session, this.tableid, this.columnDict["Boolean"], bit);
Api.SetColumn(this.session, this.tableid, this.columnDict["Byte"], b);
Api.SetColumn(this.session, this.tableid, this.columnDict["Int16"], i16);
Api.SetColumn(this.session, this.tableid, this.columnDict["UInt16"], ui16);
Api.SetColumn(this.session, this.tableid, this.columnDict["Int32"], i32);
Api.SetColumn(this.session, this.tableid, this.columnDict["UInt32"], ui32);
Api.SetColumn(this.session, this.tableid, this.columnDict["Int64"], i64);
Api.SetColumn(this.session, this.tableid, this.columnDict["UInt64"], ui64);
Api.SetColumn(this.session, this.tableid, this.columnDict["Float"], f);
Api.SetColumn(this.session, this.tableid, this.columnDict["Double"], d);
Api.SetColumn(this.session, this.tableid, this.columnDict["DateTime"], date);
Api.SetColumn(this.session, this.tableid, this.columnDict["Guid"], guid);
Api.SetColumn(this.session, this.tableid, this.columnDict["Unicode"], str, Encoding.Unicode);
Api.SetColumn(this.session, this.tableid, this.columnDict["Binary"], bytes);
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var columnValues = new ColumnValue[]
{
new BoolColumnValue { Columnid = this.columnDict["Boolean"] },
new ByteColumnValue { Columnid = this.columnDict["Byte"] },
new Int16ColumnValue { Columnid = this.columnDict["Int16"] },
new UInt16ColumnValue { Columnid = this.columnDict["UInt16"] },
new Int32ColumnValue { Columnid = this.columnDict["Int32"] },
new UInt32ColumnValue { Columnid = this.columnDict["UInt32"] },
new Int64ColumnValue { Columnid = this.columnDict["Int64"] },
new UInt64ColumnValue { Columnid = this.columnDict["UInt64"] },
new FloatColumnValue { Columnid = this.columnDict["Float"] },
new DoubleColumnValue { Columnid = this.columnDict["Double"] },
new DateTimeColumnValue { Columnid = this.columnDict["DateTime"] },
new GuidColumnValue { Columnid = this.columnDict["Guid"] },
new StringColumnValue { Columnid = this.columnDict["Unicode"] },
new BytesColumnValue { Columnid = this.columnDict["Binary"] },
};
Api.RetrieveColumns(this.session, this.tableid, columnValues);
Assert.AreEqual(bit, columnValues[0].ValueAsObject);
Assert.AreEqual(b, columnValues[1].ValueAsObject);
Assert.AreEqual(i16, columnValues[2].ValueAsObject);
Assert.AreEqual(ui16, columnValues[3].ValueAsObject);
Assert.AreEqual(i32, columnValues[4].ValueAsObject);
Assert.AreEqual(ui32, columnValues[5].ValueAsObject);
Assert.AreEqual(i64, columnValues[6].ValueAsObject);
Assert.AreEqual(ui64, columnValues[7].ValueAsObject);
Assert.AreEqual(f, columnValues[8].ValueAsObject);
Assert.AreEqual(d, columnValues[9].ValueAsObject);
Assert.AreEqual(date, columnValues[10].ValueAsObject);
Assert.AreEqual(guid, columnValues[11].ValueAsObject);
Assert.AreEqual(str, columnValues[12].ValueAsObject);
CollectionAssert.AreEqual(bytes, columnValues[13].ValueAsObject as byte[]);
}
示例13: JetRetrieveColumnsNullBuffer
public void JetRetrieveColumnsNullBuffer()
{
byte[] data = Any.Bytes;
using (var trx = new Transaction(this.session))
using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
{
Api.SetColumn(this.session, this.tableid, this.columnDict["Binary"], data);
update.SaveAndGotoBookmark();
trx.Commit(CommitTransactionGrbit.None);
}
var retrievecolumns = new[]
{
new JET_RETRIEVECOLUMN { columnid = this.columnDict["Binary"], itagSequence = 1 },
};
Assert.AreEqual(
JET_wrn.BufferTruncated,
Api.JetRetrieveColumns(this.session, this.tableid, retrievecolumns, retrievecolumns.Length));
Assert.AreEqual(data.Length, retrievecolumns[0].cbActual);
Assert.AreEqual(JET_wrn.BufferTruncated, retrievecolumns[0].err);
}
示例14: UpdateLongValues
// insert a record and update its long-values
private void UpdateLongValues()
{
Console.WriteLine("\tUpdate Long-Values");
JET_TABLEID tableid;
Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out tableid);
int recordID = NumRecords + 17;
var rand = new Random(recordID);
var data = new byte[this.columnInfos.Length][];
Api.JetBeginTransaction(this.sesid);
// insert the record
using (var update = new Update(this.sesid, tableid, JET_prep.Insert))
{
for (int i = 0; i < this.columnInfos.Length; ++i)
{
data[i] = null;
if (String.Equals(
this.columnInfos[i].Name, "recordID", StringComparison.InvariantCultureIgnoreCase))
{
// this is the primary index column, set it to the recordID
data[i] = BitConverter.GetBytes(recordID);
}
else if (this.columnInfos[i].Coltyp == JET_coltyp.LongBinary
|| this.columnInfos[i].Coltyp == JET_coltyp.LongText)
{
data[i] = DataGenerator.GetRandomColumnData(
this.columnInfos[i].Coltyp, this.columnInfos[i].Cp, rand);
}
if (null != data[i])
{
Api.SetColumn(this.sesid, tableid, this.columnInfos[i].Columnid, data[i]);
}
}
update.SaveAndGotoBookmark();
}
this.CheckColumns(this.sesid, tableid, data);
// update the record
using (var update = new Update(this.sesid, tableid, JET_prep.Replace))
{
for (int i = 0; i < this.columnInfos.Length; ++i)
{
if (this.columnInfos[i].Coltyp == JET_coltyp.LongBinary
|| this.columnInfos[i].Coltyp == JET_coltyp.LongText)
{
int size = Api.RetrieveColumnSize(this.sesid, tableid, this.columnInfos[i].Columnid).Value;
BasicClass.Assert(size == data[i].Length, "Invalid column size");
var setinfo = new JET_SETINFO();
setinfo.ibLongValue = size / 2;
setinfo.itagSequence = 1;
// the data that will be added to the column
byte[] newdata = DataGenerator.GetRandomColumnData(
this.columnInfos[i].Coltyp, this.columnInfos[i].Cp, rand);
// what the final data should be
byte[] finaldata = null;
switch (rand.Next(2))
{
case 0: // append
Api.SetColumn(
this.sesid, tableid, this.columnInfos[i].Columnid, newdata, SetColumnGrbit.AppendLV);
finaldata = new byte[size + newdata.Length];
Array.Copy(data[i], finaldata, size);
Array.Copy(newdata, 0, finaldata, size, newdata.Length);
break;
case 1: // overwrite and set size
Api.JetSetColumn(
this.sesid,
tableid,
this.columnInfos[i].Columnid,
newdata,
newdata.Length,
SetColumnGrbit.SizeLV | SetColumnGrbit.OverwriteLV,
setinfo);
finaldata = new byte[setinfo.ibLongValue + newdata.Length];
Array.Copy(data[i], finaldata, setinfo.ibLongValue);
Array.Copy(newdata, 0, finaldata, setinfo.ibLongValue, newdata.Length);
break;
}
data[i] = finaldata;
}
}
update.SaveAndGotoBookmark();
}
this.CheckColumns(this.sesid, tableid, data);
Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);
//.........这里部分代码省略.........
示例15: InsertCopy
// Inserts a copy of a record and makes sure the data is equal
private void InsertCopy()
{
Console.WriteLine("\tInsertCopy");
JET_TABLEID tableid;
Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out tableid);
Api.JetBeginTransaction(this.sesid);
this.SeekRecord(this.sesid, tableid, NumRecords / 2);
byte[][] data = this.GetColumnsWithJetRetrieveColumn(this.sesid, tableid);
using (var update = new Update(this.sesid, tableid, JET_prep.InsertCopy))
{
for (int i = 0; i < this.columnInfos.Length; ++i)
{
int recordID = NumRecords + 13;
if (String.Equals(
this.columnInfos[i].Name, "recordID", StringComparison.InvariantCultureIgnoreCase))
{
// this is the primary index column, set it to the new recordID
data[i] = BitConverter.GetBytes(recordID);
Api.SetColumn(this.sesid, tableid, this.columnInfos[i].Columnid, data[i]);
}
}
update.SaveAndGotoBookmark();
}
this.CheckColumns(this.sesid, tableid, data);
Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);
Api.JetCloseTable(this.sesid, tableid);
}