Last active
December 25, 2015 04:39
-
-
Save hyrmn/6919298 to your computer and use it in GitHub Desktop.
Patching in RavenDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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