Question

According to RavenDB document, when BeforeStore() returns false, the entity instance should not updated.

Whatever the entity instance was modified and requires us re-serialize it. Returning true would force re-serialization of the entity, returning false would mean that any changes to the entityInstance would be ignored in the current SaveChanges call.

I have tested return both true and false, no difference. Return false won't stop saving the entity to database.

Here is my listener:

public bool BeforeStore(string key, object entityInstance, RavenJObject metadata, RavenJObject original)
{
    if (entityInstance is Person)
    {
        var person = (Person)entityInstance;
        person.Firstname = "Tom"; // used be John
        return false;
    }
}

It turns out the person's first name is changed to "Tom" even it returns false. Do I miss anything?

Was it helpful?

Solution

Please re-read the documentation. The return value just says whether you have changed the document in your IDocumentStoreListener.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top