Microsoft.Isam.Esent.Interop.Update.SaveAndGotoBookmark C# (CSharp) Method

SaveAndGotoBookmark() public method

Update the tableid and position the tableid on the record that was modified. This can be useful when inserting a record because by default the tableid remains in its old location.
Save is the final step in performing an insert or an update. The update is begun by calling creating an Update object and then by calling JetSetColumn or JetSetColumns one or more times to set the record state. Finally, Update is called to complete the update operation. Indexes are updated only by Update or and not during JetSetColumn or JetSetColumns
public SaveAndGotoBookmark ( ) : void
return void
        public void SaveAndGotoBookmark()
        {
            var bookmark = bookmarkCache.Allocate();
            int actualBookmarkSize;
            this.Save(bookmark, bookmark.Length, out actualBookmarkSize);
            Api.JetGotoBookmark(this.sesid, this.tableid, bookmark, actualBookmarkSize);
            bookmarkCache.Free(bookmark);
        }

Usage Example

Exemplo n.º 1
0
		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();
			}
		}
All Usage Examples Of Microsoft.Isam.Esent.Interop.Update::SaveAndGotoBookmark