Skip to content

Instantly share code, notes, and snippets.

@hyrmn
Last active December 25, 2015 04:39
Show Gist options
  • Select an option

  • Save hyrmn/6919298 to your computer and use it in GitHub Desktop.

Select an option

Save hyrmn/6919298 to your computer and use it in GitHub Desktop.
Patching in RavenDB
public class PosItemProjection_ByCategoryId : AbstractIndexCreationTask<PosItemProjection>
{
public PosItemProjection_ByCategoryId()
{
Map = items => from item in items select new { item.CategoryId };
Index(x => x.CategoryId, FieldIndexing.NotAnalyzed);
}
}
private void BulkUpdateItemsInCategory(string categoryId, string propertyToUpdate, string newValue)
{
var query = "CategoryId:\"{0}\"".FormatWith(categoryId);
_store.DatabaseCommands.UpdateByIndex("PosItemProjection/ByCategoryId",
new IndexQuery { Query = query },
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = propertyToUpdate,
Value = newValue
}
},
allowStale: true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment