/// <summary> /// Method used internally to generate position-based database patch request /// </summary> /// <param name="propertyName">Name of the property to patch</param> /// <param name="pos">Position to use with the patch command</param> /// <param name="type">Type of the patch command</param> /// <returns>THe patch request that has been generated</returns> private PatchRequest generatePatchRequest(string propertyName, int pos, PatchCommandType type) { return(new PatchRequest { Type = type, Name = propertyName, Position = pos, Value = null }); }
/// <summary> /// Method used internally to generate value-based database patch request /// </summary> /// <param name="propertyName">Name of the property to patch</param> /// <param name="value">Value to use with patch command</param> /// <param name="type">Type of the patch command</param> /// <returns>The patch request generated</returns> private PatchRequest generatePatchRequest(string propertyName, object value, PatchCommandType type) { return(new PatchRequest { Type = type, Name = propertyName, Value = JToken.FromObject(value) }); }
/// <summary> /// Method used internally to patch the database. /// </summary> /// <param name="key">RavenDB key of the element to patch</param> /// <param name="propertyName">Name of the property to patch</param> /// <param name="value">Value used for executing patching command</param> /// <param name="type">Type of Patch Command</param> /// <returns>Always True</returns> private bool patchDatabase(string key, string propertyName, object value, PatchCommandType type) { lock (_store) { using (IDocumentSession _session = _store.OpenSession()) { Raven.Database.BatchResult[] res = _session.Advanced.DatabaseCommands.Batch( new[] { new PatchCommandData { Key = key, Patches = new [] { generatePatchRequest(propertyName, value, type) } } } ); } } return(true); }