Let's assume I have the following domain:
public class Movie
{
public string Id { get; set; }
public string Name { get; set; }
public List<ActorReference> Actors { get; set; }
}
public class Actor
{
public string Id { get; set; }
public string Name { get; set; }
public string Biography { get; set; }
public string AnotherDetailProperty { get; set; }
}
public class ActorReference
{
public string Id { get; set; }
public string Name { get; set; }
}
Now, if the name of an actor changes I want to make sure, that all referencing movies are updated as well. Therefore, I first create an Index which let me query all movies in which a specific actor is involved:
public class Movies_ByActorId : AbstractIndexCreationTask<Movie>
{
public Movies_ByActorId()
{
Map = movies => from movie in movies
from actor in movie.Actors
select new { ActorId = actor.Id };
}
}
Ok, now I would like to fire the patch-command...
Session.Advanced.DatabaseCommands.UpdateByIndex(
"Movies/ByActorId",
new IndexQuery
{
Query = "ActorId:" + actorWhoseNameHasChanged.Id
},
new[]
{
new PatchRequest
{
Type = PatchCommandType.Modify,
Name = "Actors",
Nested = new[]
{
// WHAT TO DO HERE?
}
}
},
allowStale: false);
Could someone please help me complete this code-block above, since I have absolutely no idea, how I can only update the name of the denormalized references which represent the changed actor.
I'm afraid RavenDB doesn't support this kind of patch-request and I need to load and store all movies manually, which is something I would definitely want to avoid for performance reasons.