コード例 #1
0
 public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, PatchRequest[] patchRequests, bool allowStale)
 {
     return(PerformBulkOperation(indexName, queryToUpdate, allowStale, (docId, tx) =>
     {
         var patchResult = database.ApplyPatch(docId, null, patchRequests, tx);
         return new { Document = docId, Result = patchResult };
     }));
 }
コード例 #2
0
        public static void Execute(this ICommandData self, DocumentDatabase database)
        {
            var deleteCommandData = self as DeleteCommandData;

            if (deleteCommandData != null)
            {
                database.Delete(deleteCommandData.Key, deleteCommandData.Etag, deleteCommandData.TransactionInformation);
                return;
            }

            var putCommandData = self as PutCommandData;

            if (putCommandData != null)
            {
                var putResult = database.Put(putCommandData.Key, putCommandData.Etag, putCommandData.Document, putCommandData.Metadata, putCommandData.TransactionInformation);
                putCommandData.Etag = putResult.ETag;
                putCommandData.Key  = putResult.Key;

                return;
            }

            var patchCommandData = self as PatchCommandData;

            if (patchCommandData != null)
            {
                database.ApplyPatch(patchCommandData.Key, patchCommandData.Etag, patchCommandData.Patches, patchCommandData.TransactionInformation);

                var doc = database.Get(patchCommandData.Key, patchCommandData.TransactionInformation);
                if (doc != null)
                {
                    patchCommandData.Metadata = doc.Metadata;
                    patchCommandData.Etag     = doc.Etag;
                }
                return;
            }

            var advPatchCommandData = self as ScriptedPatchCommandData;

            if (advPatchCommandData != null)
            {
                var result = database.ApplyPatch(advPatchCommandData.Key, advPatchCommandData.Etag,
                                                 advPatchCommandData.Patch, advPatchCommandData.TransactionInformation, advPatchCommandData.DebugMode);

                if (advPatchCommandData.DebugMode)
                {
                    advPatchCommandData.AdditionalData = result.Item1.Document;
                    return;
                }

                var doc = database.Get(advPatchCommandData.Key, advPatchCommandData.TransactionInformation);
                if (doc != null)
                {
                    advPatchCommandData.Metadata = doc.Metadata;
                    advPatchCommandData.Etag     = doc.Etag;
                }
                return;
            }
        }
コード例 #3
0
ファイル: CommandExtensions.cs プロジェクト: nberardi/ravendb
		public static void Execute(this ICommandData self, DocumentDatabase database)
		{
			var deleteCommandData = self as DeleteCommandData;
			if (deleteCommandData != null)
			{
				database.Delete(deleteCommandData.Key, deleteCommandData.Etag, deleteCommandData.TransactionInformation);
				return;
			}

			var putCommandData = self as PutCommandData;
			if (putCommandData != null)
			{
				var putResult = database.Put(putCommandData.Key, putCommandData.Etag, putCommandData.Document, putCommandData.Metadata, putCommandData.TransactionInformation);
				putCommandData.Etag = putResult.ETag;
				putCommandData.Key = putResult.Key;

				return;
			}

			var patchCommandData = self as PatchCommandData;
			if (patchCommandData != null)
			{
				database.ApplyPatch(patchCommandData.Key, patchCommandData.Etag, patchCommandData.Patches, patchCommandData.TransactionInformation);

				var doc = database.Get(patchCommandData.Key, patchCommandData.TransactionInformation);
				if (doc != null)
				{
					patchCommandData.Metadata = doc.Metadata;
					patchCommandData.Etag = doc.Etag;
				}
				return;
			}

			var advPatchCommandData = self as ScriptedPatchCommandData;
			if (advPatchCommandData != null)
			{
				var result = database.ApplyPatch(advPatchCommandData.Key, advPatchCommandData.Etag,
									advPatchCommandData.Patch, advPatchCommandData.TransactionInformation, advPatchCommandData.DebugMode);

				if(advPatchCommandData.DebugMode)
				{
					advPatchCommandData.AdditionalData = result.Item1.Document;
					return;
				}

				var doc = database.Get(advPatchCommandData.Key, advPatchCommandData.TransactionInformation);
				if (doc != null)
				{
					advPatchCommandData.Metadata = doc.Metadata;
					advPatchCommandData.Etag = doc.Etag;
				}
				return;
			}
		}
コード例 #4
0
		public void Execute(DocumentDatabase database)
		{
			database.ApplyPatch(Key, Etag, Patches, TransactionInformation);

			var doc = database.Get(Key, TransactionInformation);
			if (doc != null)
				Metadata = doc.Metadata;
		}
コード例 #5
0
        public void Execute(DocumentDatabase database)
        {
            database.ApplyPatch(Key, Etag, Patches, TransactionInformation);

            var doc = database.Get(Key, TransactionInformation);

            if (doc != null)
            {
                Metadata = doc.Metadata;
            }
        }
コード例 #6
0
 public void Execute(DocumentDatabase database)
 {
     database.ApplyPatch(Key, Etag, Patches, TransactionInformation);
 }
コード例 #7
0
ファイル: PatchCommandData.cs プロジェクト: kenegozi/ravendb
 public void Execute(DocumentDatabase database)
 {
     database.ApplyPatch(Key, Etag, Patches, TransactionInformation);
 }
コード例 #8
0
ファイル: CommandExtensions.cs プロジェクト: ybdev/ravendb
        private static void Execute(ICommandData self, DocumentDatabase database, BatchResult batchResult)
        {
            var deleteCommandData = self as DeleteCommandData;

            if (deleteCommandData != null)
            {
                var result = database.Delete(deleteCommandData.Key, deleteCommandData.Etag, deleteCommandData.TransactionInformation);

                if (batchResult != null)
                {
                    batchResult.Deleted = result;
                }

                return;
            }

            var putCommandData = self as PutCommandData;

            if (putCommandData != null)
            {
                var putResult = database.Put(putCommandData.Key, putCommandData.Etag, putCommandData.Document, putCommandData.Metadata, putCommandData.TransactionInformation);
                putCommandData.Etag = putResult.ETag;
                putCommandData.Key  = putResult.Key;

                return;
            }

            var patchCommandData = self as PatchCommandData;

            if (patchCommandData != null)
            {
                var result = database.ApplyPatch(patchCommandData.Key, patchCommandData.Etag,
                                                 patchCommandData.Patches, patchCommandData.PatchesIfMissing, patchCommandData.Metadata,
                                                 patchCommandData.TransactionInformation);

                if (batchResult != null)
                {
                    batchResult.PatchResult = result.PatchResult;
                }

                var doc = database.Get(patchCommandData.Key, patchCommandData.TransactionInformation);
                if (doc != null)
                {
                    database.TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() =>
                    {
                        patchCommandData.Metadata = doc.Metadata;
                        patchCommandData.Etag     = doc.Etag;
                    });
                }
                return;
            }

            var advPatchCommandData = self as ScriptedPatchCommandData;

            if (advPatchCommandData != null)
            {
                var result = database.ApplyPatch(advPatchCommandData.Key, advPatchCommandData.Etag,
                                                 advPatchCommandData.Patch, advPatchCommandData.PatchIfMissing, advPatchCommandData.Metadata,
                                                 advPatchCommandData.TransactionInformation, advPatchCommandData.DebugMode);

                if (batchResult != null)
                {
                    batchResult.PatchResult = result.Item1.PatchResult;
                }

                advPatchCommandData.AdditionalData = new RavenJObject {
                    { "Debug", new RavenJArray(result.Item2) }
                };
                if (advPatchCommandData.DebugMode)
                {
                    advPatchCommandData.AdditionalData["Document"] = result.Item1.Document;
                    return;
                }

                var doc = database.Get(advPatchCommandData.Key, advPatchCommandData.TransactionInformation);
                if (doc != null)
                {
                    database.TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() =>
                    {
                        advPatchCommandData.Metadata = doc.Metadata;
                        advPatchCommandData.Etag     = doc.Etag;
                    });
                }
                return;
            }
        }
コード例 #9
0
ファイル: CommandExtensions.cs プロジェクト: 925coder/ravendb
		private static void Execute(ICommandData self, DocumentDatabase database, BatchResult batchResult)
		{
			var deleteCommandData = self as DeleteCommandData;
			if (deleteCommandData != null)
			{
				var result = database.Delete(deleteCommandData.Key, deleteCommandData.Etag, deleteCommandData.TransactionInformation);

				if (batchResult != null)
					batchResult.Deleted = result;

				return;
			}

			var putCommandData = self as PutCommandData;
			if (putCommandData != null)
			{
				var putResult = database.Put(putCommandData.Key, putCommandData.Etag, putCommandData.Document, putCommandData.Metadata, putCommandData.TransactionInformation);
				putCommandData.Etag = putResult.ETag;
				putCommandData.Key = putResult.Key;

				return;
			}

			var patchCommandData = self as PatchCommandData;
			if (patchCommandData != null)
			{
				var result = database.ApplyPatch(patchCommandData.Key, patchCommandData.Etag,
												 patchCommandData.Patches, patchCommandData.PatchesIfMissing, patchCommandData.Metadata,
												 patchCommandData.TransactionInformation);

				if (batchResult != null)
					batchResult.PatchResult = result.PatchResult;

				var doc = database.Get(patchCommandData.Key, patchCommandData.TransactionInformation);
				if (doc != null)
				{
					database.TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() =>
					{
						patchCommandData.Metadata = doc.Metadata;
						patchCommandData.Etag = doc.Etag;
					});
				}
				return;
			}

			var advPatchCommandData = self as ScriptedPatchCommandData;
			if (advPatchCommandData != null)
			{
				var result = database.ApplyPatch(advPatchCommandData.Key, advPatchCommandData.Etag,
												 advPatchCommandData.Patch, advPatchCommandData.PatchIfMissing, advPatchCommandData.Metadata,
												 advPatchCommandData.TransactionInformation, advPatchCommandData.DebugMode);

				if (batchResult != null)
					batchResult.PatchResult = result.Item1.PatchResult;

				advPatchCommandData.AdditionalData = new RavenJObject { { "Debug", new RavenJArray(result.Item2) } };
				if(advPatchCommandData.DebugMode)
				{
					advPatchCommandData.AdditionalData["Document"] = result.Item1.Document;
					return;
				}

				var doc = database.Get(advPatchCommandData.Key, advPatchCommandData.TransactionInformation);
				if (doc != null)
				{
					database.TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() =>
					{
						advPatchCommandData.Metadata = doc.Metadata;
						advPatchCommandData.Etag = doc.Etag;
					});
				}
				return;
			}
		}