Closed bdongus closed 4 years ago
Hi. From what I see, everything looks correct.
Does it work if you don’t use snapshots? So just use the repository? If so, my guess is that there is something wrong in the snapshots restore method or the event store.
It’s very hard for me to know without being able to debug the code, but as said, it looks correct from here.
Hi, It did work before switching the aggregate to a snapshot aggregate.
The snapshot store returns the snapshot with version 125. The event store then returns an empty array. There is no event beyond version 125. The "RestoreFromSnapshot" method on my aggregate root is never called.
Guess that's the problem. Any ideas why this happens?
That’s strange. Can you debug into CQRSlite and see what happens? Is the Restore method called in the SnapshotAggregateroot? And what happens inside TryRestoreAggregateFromSnapshot in snapshotrepostiory.
Unfortunately I’m on vacation without a computer until the weekend, so can’t really debug to much myself.
I will downlaod the source and debug this. Enjoy your vacation.
Inside TryRestoreAggregateFromSnapshot
aggregate.Invoke("Restore", snapshot);
is executed. In the DynamicInvoker
var exists = _cachedMembers.TryGetValue(hash, out var method);
if (exists) return method?.Invoke(obj, args);
exists is true, but method is null.
This happens because I use different types in the store (SnapshotEntry) and in the snapshot aggregate (GenericSnapshot
Might not be the best idea to handle this. Which leads me to a question: What is the recommended way to work with snapshots seralizing/deserializing them to/from some kind of disk storage? Is there a working sample?
ooops ... misclicked and closed the issue accidently.
Hi. There are as far as I know no working samples in the wild. I have only used it in closed source projects myself, and haven't actually used snapshotting in a while.
I haven't ever tried using a generic snapshot or anything not made for each aggregate so I'm a bit lost here.
Would it work with regular dynamic invoking? If so, maybe I could find a way to invoke if method is null in the code quoted above.
Sorry for the delay. I think my way isn't as smart as I thought. I will use dedicated snapshots per aggregate. If I stumble upon something else, I'll ask again.
Have a nice week.
Hi.
Probably I am doing something wrong, but I have no idea what. This is my test code:
My assert expects 125 but 0 is returned. The guid is the default guid. Not the aggregates guid.
What could cause that behaviour?
I am using version 1.32.1.