本文整理汇总了C#中RavenJObject.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJObject.ToBytes方法的具体用法?C# RavenJObject.ToBytes怎么用?C# RavenJObject.ToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJObject
的用法示例。
在下文中一共展示了RavenJObject.ToBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutMappedResult
public void PutMappedResult(string view, string docId, string reduceKey, RavenJObject data, byte[] viewAndReduceKeyHashed)
{
Guid etag = uuidGenerator.CreateSequentialUuid();
using (var update = new Update(session, MappedResults, JET_prep.Insert))
{
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["view"], view, Encoding.Unicode);
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["document_key"], docId, Encoding.Unicode);
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["reduce_key"], reduceKey, Encoding.Unicode);
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["reduce_key_and_view_hashed"], viewAndReduceKeyHashed);
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["data"], data.ToBytes());
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["etag"], etag.TransformToValueForEsentSorting());
Api.SetColumn(session, MappedResults, tableColumnsCache.MappedResultsColumns["timestamp"], DateTime.Now);
update.Save();
}
}
示例2: AddDocumentInTransaction
public Guid AddDocumentInTransaction(string key, Guid? etag, RavenJObject data, RavenJObject metadata, TransactionInformation transactionInformation)
{
var readResult = storage.Documents.Read(new RavenJObject {{"key", key}});
if (readResult != null) // update
{
StorageHelper.AssertNotModifiedByAnotherTransaction(storage, this, key, readResult, transactionInformation);
AssertValidEtag(key, readResult, storage.DocumentsModifiedByTransactions.Read(new RavenJObject { { "key", key } }), etag);
((RavenJObject)readResult.Key)["txId"] = transactionInformation.Id.ToByteArray();
if (storage.Documents.UpdateKey(readResult.Key) == false)
throw new ConcurrencyException("PUT attempted on document '" + key +
"' that is currently being modified by another transaction");
}
else
{
readResult = storage.DocumentsModifiedByTransactions.Read(new RavenJObject { { "key", key } });
StorageHelper.AssertNotModifiedByAnotherTransaction(storage, this, key, readResult, transactionInformation);
}
storage.Transactions.UpdateKey(new RavenJObject
{
{"txId", transactionInformation.Id.ToByteArray()},
{"timeout", SystemTime.UtcNow.Add(transactionInformation.Timeout)}
});
var ms = new MemoryStream();
metadata.WriteTo(ms);
var dataBytes = documentCodecs.Aggregate(data.ToBytes(), (bytes, codec) => codec.Encode(key, data, metadata, bytes));
ms.Write(dataBytes, 0, dataBytes.Length);
var newEtag = generator.CreateSequentialUuid();
storage.DocumentsModifiedByTransactions.Put(new RavenJObject
{
{"key", key},
{"etag", newEtag.ToByteArray()},
{"modified", SystemTime.UtcNow},
{"txId", transactionInformation.Id.ToByteArray()}
}, ms.ToArray());
return newEtag;
}