public class Movie
{
public string Id {get; set; }
public string Name {get; set; }
public ListActors {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 actor’s name changes, I want to make sure that all referenced movies are also updated. Therefore, I first create an index that allows me to query for specific actors All movies:
public class Movies_ByActorId: AbstractIndexCreationTask
{
public Movies_ByActorId()
{
Map = movies => from movie in movies
from actor in movie.Actors
select new {ActorId = actor.Id };
}
}< /pre>Okay, now I want to fire the patch command...
Session.Advanced.DatabaseCommands.UpdateByIndex(
"Movies/ByActorId",< br /> new IndexQuery
{
Query = "ActorId:" + actorWhoseNameHasChanged.Id
},
new[]
{
new PatchRequest
{
Type = PatchCommandType.Modify,
Name = "Actors",
Nested = new[]
{
// WHAT TO DO HERE?
}
}
},
allowStale: false);Someone can help me complete the above code block, because I don’t know at all, how can I just Update the name of the denormalized reference representing the changed actor.
I am worried that RavenDB does not support this kind of patch request, and I need to manually load and store all movies, which I definitely want to avoid for performance reasons.
We assume that I have the following domain names:
public class Movie
{
public string Id {get; set; }
public string Name {get; set; }
public ListActors {ge t; 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
{< br /> public string Id {get; set; }
public string Name {get; set; }
}
Now, if the actor name changes, I want to make sure that all references Movies will also be updated. Therefore, I first create an index that allows me to query all movies involving a specific actor:
public class Movies_ByActorId: AbstractIndexCreationTask
{
public Movies_ByActorId()
{
Map = movies => from movie in movies
from actor in movie.Actors
select new {ActorId = actor.Id };
}
}
Ok, now I want 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);
< p>Can someone help me complete the above code block, because I have no idea, how can I only update the name of the denormalized reference representing the changed actor.
I am worried that RavenDB does not support this kind of patch request , I need to manually load and store all movies, which I definitely want to avoid for performance reasons.
RavenDB does not support patch-based standards. You can Solve the problem without denormalized references, and use include when reading.