Thank you! That’s more or less what I was wanting to confirm. If this was the appropriate use of PatchRequest, or if I had just designed something terrible.
Thank you! That’s more or less what I was wanting to confirm. If this was the appropriate use of PatchRequest, or if I had just designed something terrible.
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var patch = RavenPatch.For<Document>("documents/1")
.Set(d => d.Something, "bla bla")
.Unset(d => d.UselessStuff)
.Add(d => d.SomeList, 1337)
.Build();
session.Advanced.Defer(patch);
// Or execute right away.
store.DatabaseCommands.Batch(new[] { patch });
Have you considered ScriptedPatch? Personally I find it easier to work with.
On Tue, Aug 23, 2016 at 3:23 PM, Stacey Thornton <stacey.ci...@gmail.com> wrote:
Thank you! That’s more or less what I was wanting to confirm. If this was the appropriate use of PatchRequest, or if I had just designed something terrible.
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Oh wow! I am very interested, yes! I would love to have this bit of code. That would simplify things greatly!
--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/OkP8KAaTfqw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
_session.Patch<Document>("documents/1")
.Set(d => d.Property, "value")
// etc
.Defer();
_session.Patch<Document>("documents/1")
.Set(d => d.Property, "value")
// etc
.Execute();
string removeCarFromStationScript = $"var i = this.{nameof(StationDocument.CarIdsQueue)}.indexOf(carId); if (i !== -1) this.{nameof(StationDocument.CarIdsQueue)}.splice(i, 1)";
var script = RavenScript.For(car.CurrentStationId)
.Script(removeCarFromStationScript)
.Parameters(new { carId = car.Id })
.Build();
var carPatch = RavenPatch.For<CarDocument>(car.Id) .Set(c => c.Status, CarStatus.Free) .Unset(c => c.CurrentStationId) .Build();
await _raven.Commands.ExecuteAsync(carPatch, stationScript);