Вопрос

I need to perform edits on my saga documents outside of the saga. I am trying to do the simple property update which is:

                SaleSaga saga = session.Load<SaleSaga>(id);
                saga.SaleSagaTaskId = taskId;
                session.SaveChanges();

This does not work, I end up with this issue.

    {"Entity Messages.SaleSaga had document key 'salesaga/d6b639c4-78a1-4be6-8e44-a283010b11a9' 
but now has document key property 'salesagas/d6b639c4-78a1-4be6-8e44-a283010b11a9'
.\r\nYou cannot change the document key property of a entity loaded into the session"}

I am not sure why it is adding an 's' on to the end of "salesagas". I'm at a loss as to the best way to resolve this, any help would be greatly appreciated.

EDIT: This is for an NServiceBus saga and the error is occurring when attempting to save the edited document back to RavenDB.

Это было полезно?

Решение

The NServiceBus Saga Persister uses different conventions for storing sagas than the Raven default conventions. The Raven default convention is to take the class name and pluralize it. Apparently NServiceBus does not do so. So you have a mismatch by accessing the data in fundamentally different ways.

You may want to reuse the NServiceBus Saga Persister class. The Saga persistence code can be found here:

https://github.com/Particular/NServiceBus/tree/4.2.0/src/NServiceBus.Core/Persistence/Raven

Другие советы

How was the original object written? It looks to me like the reader and writer of this data might be two different systems, or two different versions of this system, and the the document conventions have changed.

Either use the original convention, or use a string identifier instead of a Guid.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top