本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Transaction类的典型用法代码示例。如果您正苦于以下问题:C# Transaction类的具体用法?C# Transaction怎么用?C# Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于Microsoft.Isam.Esent.Interop命名空间,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StorageActionsAccessor
public StorageActionsAccessor(TableColumnsCache tableColumnsCache, JET_INSTANCE instance, string databaseName, UuidGenerator uuidGenerator, OrderedPartCollection<AbstractFileCodec> fileCodecs)
{
this.tableColumnsCache = tableColumnsCache;
this.uuidGenerator = uuidGenerator;
this.fileCodecs = fileCodecs;
try
{
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, databaseName, null, out database, OpenDatabaseGrbit.None);
}
catch (Exception original)
{
log.WarnException("Could not create accessor", original);
try
{
Dispose();
}
catch (Exception e)
{
log.WarnException("Could not properly dispose accessor after exception in ctor.", e);
}
throw;
}
}
开发者ID:GorelH,项目名称:ravendb,代码行数:25,代码来源:StorageActionsAccessor.cs
示例2: 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);
}
}
开发者ID:Artoymyp,项目名称:XbimEssentials,代码行数:31,代码来源:XbimHeaderTable.cs
示例3: 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);
}
}
开发者ID:simonkang,项目名称:NAppProfiler,代码行数:26,代码来源:IndexTableSchema.cs
示例4: Create
public void Create(TableDefinition def)
{
if (def.ColumnDefinitions.FindAll(x => x.IsPrimaryKey).Count != 1)
{
// TODO do we allow 0 primary keys?
throw new EseException("Ensure one primary key is defined for the table");
}
using (var transaction = new Transaction(connection.session))
{
JET_TABLEID tableid;
Api.JetCreateTable(connection.session, connection.dbid, def.TableName, 16, 100, out tableid);
foreach (var column in def.ColumnDefinitions) {
AddColumn(tableid, column);
}
foreach (var item in def.Indexes) {
// all indexes are ascending
var indexName = string.Join("|", item.ToArray());
var indexDef = "+" + string.Join("\0+", item.ToArray()) + "\0\0";
Api.JetCreateIndex(connection.session, tableid, indexName, CreateIndexGrbit.IndexSortNullsHigh, indexDef, indexDef.Length, 100);
}
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
开发者ID:purplecow,项目名称:simplestorageengine,代码行数:28,代码来源:EseTableCreator.cs
示例5: PopImpl
protected override CrawlerQueueEntry PopImpl()
{
return m_EsentInstance.Cursor((session, dbid) =>
{
using (Transaction transaction = new Transaction(session))
{
using (Table table = new Table(session, dbid, EsentTableDefinitions.QueueTableName, OpenTableGrbit.None))
{
if (Api.TryMoveFirst(session, table))
{
byte[] data = Api.RetrieveColumn(session, table, dataColumn.columnid);
Api.JetDelete(session, table);
using (Table table2 = new Table(session, dbid, EsentTableDefinitions.GlobalsTableName, OpenTableGrbit.None))
{
Api.EscrowUpdate(session, table2, queueCountColumn.columnid, -1);
}
transaction.Commit(CommitTransactionGrbit.None);
return data.FromBinary<CrawlerQueueEntry>();
}
}
transaction.Rollback();
return null;
}
});
}
开发者ID:osamede,项目名称:social_listen,代码行数:28,代码来源:EsentCrawlQueueService.cs
示例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);
}
}
开发者ID:stantoxt,项目名称:rhino-queues,代码行数:25,代码来源:SchemaCreator.cs
示例7: DocumentStorageActions
public DocumentStorageActions(
JET_INSTANCE instance,
string database,
TableColumnsCache tableColumnsCache,
OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
IUuidGenerator uuidGenerator,
IDocumentCacher cacher,
TransactionalStorage transactionalStorage)
{
this.tableColumnsCache = tableColumnsCache;
this.documentCodecs = documentCodecs;
this.uuidGenerator = uuidGenerator;
this.cacher = cacher;
this.transactionalStorage = transactionalStorage;
try
{
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
}
catch (Exception)
{
Dispose();
throw;
}
}
开发者ID:carlosagsmendes,项目名称:ravendb,代码行数:26,代码来源:General.cs
示例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);
}
}
}
开发者ID:seantarogers,项目名称:ReliableSignalRMessaging,代码行数:32,代码来源:MessageStoreServiceTests.cs
示例9: 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
示例10: 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;
}
}
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:EsentStorage.StringNameTableAccessor.cs
示例11: 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);
}
}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:27,代码来源:From26To27.cs
示例12: 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);
}
}
}
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:28,代码来源:XpCompatabilityTests.cs
示例13: AbstractActions
protected AbstractActions(JET_INSTANCE instance, ColumnsInformation columnsInformation, string database, Guid instanceId)
{
logger = LogManager.GetLogger(GetType());
try
{
this.instanceId = instanceId;
ColumnsInformation = columnsInformation;
session = new Session(instance);
transaction = new Transaction(session);
Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
queues = new EsentTable(session, new Table(session, dbid, "queues", OpenTableGrbit.None));
subqueues = new EsentTable(session, new Table(session, dbid, "subqueues", OpenTableGrbit.None));
txs = new EsentTable(session, new Table(session, dbid, "transactions", OpenTableGrbit.None));
recovery = new EsentTable(session, new Table(session, dbid, "recovery", OpenTableGrbit.None));
outgoing = new EsentTable(session, new Table(session, dbid, "outgoing", OpenTableGrbit.None));
outgoingHistory = new EsentTable(session, new Table(session, dbid, "outgoing_history", OpenTableGrbit.None));
recveivedMsgs = new EsentTable(session, new Table(session, dbid, "recveived_msgs", OpenTableGrbit.None));
}
catch (Exception)
{
Dispose();
throw;
}
}
开发者ID:jmptrader,项目名称:LightningQueues,代码行数:26,代码来源:AbstractActions.cs
示例14: 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);
}
}
开发者ID:kenegozi,项目名称:ravendb,代码行数:29,代码来源:From24To24.cs
示例15: 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);
}
}
开发者ID:philiphoy,项目名称:ravendb,代码行数:28,代码来源:SchemaCreator.cs
示例16: 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);
}
}
开发者ID:925coder,项目名称:ravendb,代码行数:33,代码来源:SchemaCreator.cs
示例17: CreateTable
internal static void CreateTable(JET_SESID sesid, JET_DBID dbid)
{
JET_TABLEID tableid;
Api.JetCreateTable(sesid, dbid, GeometryTableName, 8, 80, out tableid);
using (var transaction = new Microsoft.Isam.Esent.Interop.Transaction(sesid))
{
JET_COLUMNID columnid;
var columndef = new JET_COLUMNDEF
{
coltyp = JET_coltyp.Long,
grbit = ColumndefGrbit.ColumnAutoincrement
};
Api.JetAddColumn(sesid, tableid, colNameGeometryLabel, columndef, null, 0, out columnid);
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameProductLabel, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.UnsignedByte;
Api.JetAddColumn(sesid, tableid, colNameGeomType, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Short;
Api.JetAddColumn(sesid, tableid, colNameProductIfcTypeId, columndef, null, 0, out columnid);
Api.JetAddColumn(sesid, tableid, colNameSubPart, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Binary;
columndef.grbit = ColumndefGrbit.ColumnMaybeNull;
Api.JetAddColumn(sesid, tableid, colNameTransformMatrix, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.LongBinary;
//if (EsentVersion.SupportsWindows7Features)
// columndef.grbit |= Windows7Grbits.ColumnCompressed;
Api.JetAddColumn(sesid, tableid, colNameShapeData, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Long;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameGeometryHash, columndef, null, 0, out columnid);
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameStyleLabel, columndef, null, 0, out columnid);
// The primary index is the type and the entity label.
string indexDef = string.Format("+{0}\0\0", colNameGeometryLabel);
Api.JetCreateIndex(sesid, tableid, geometryTablePrimaryIndex, CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 100);
//create index by geometry hashes
indexDef = string.Format("+{0}\0\0", colNameGeometryHash);
Api.JetCreateIndex(sesid, tableid, geometryTableHashIndex, CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length, 100);
//Create index by product
indexDef = string.Format("+{0}\0{1}\0{2}\0{3}\0{4}\0\0", colNameGeomType, colNameProductIfcTypeId, colNameProductLabel, colNameSubPart, colNameStyleLabel);
Api.JetCreateIndex(sesid, tableid, geometryTableGeomTypeIndex, CreateIndexGrbit.IndexUnique, indexDef, indexDef.Length, 100);
//create index by style
indexDef = string.Format("+{0}\0{1}\0{2}\0{3}\0{4}\0\0", colNameGeomType, colNameStyleLabel, colNameProductIfcTypeId, colNameProductLabel, colNameGeometryLabel);
Api.JetCreateIndex(sesid, tableid, geometryTableStyleIndex, CreateIndexGrbit.None, indexDef, indexDef.Length, 100);
Api.JetCloseTable(sesid, tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}
开发者ID:Artoymyp,项目名称:XbimEssentials,代码行数:60,代码来源:XbimGeometryCursor.cs
示例18: 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);
}
}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:59,代码来源:From21To22.cs
示例19: 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
示例20: 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);
}
开发者ID:ayende,项目名称:managed-esent,代码行数:58,代码来源:TempTableFixture.cs
注:本文中的Microsoft.Isam.Esent.Interop.Transaction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论