当前位置: 首页>>代码示例>>C#>>正文


C# RavenJObject.ToBytes方法代码示例

本文整理汇总了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();
			}
		}
开发者ID:wbinford,项目名称:ravendb,代码行数:17,代码来源:MappedResults.cs

示例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;
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:42,代码来源:TransactionStorageActions.cs


注:本文中的RavenJObject.ToBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。