pjvds / ncqrs

Ncqrs Framework - The CQRS Framework for .NET
Other
542 stars 162 forks source link

Entity and EntityMappedByConvention now Serializable #33

Closed house9 closed 13 years ago

house9 commented 13 years ago

Entity and EntityMappedByConvention are now marked Serializable, this allows snapshotting of AR that contain entities.

chrisnicola commented 13 years ago

Hmm, I'm not sure about this shouldn't you create mementos of the entities too? An aggregate root is just an Entity that is marked as root (despite the fact that they are separate classes in NCQRS).

I'm not sure we should be serializing classes that are supposed to encapsulate their state, perhaps we just need a more extensive ISnapshottable concept that extends to the entities.

house9 commented 13 years ago

fair enough, it was a quick fix so that I could save my AR with Entities into the snapshot

pjvds commented 13 years ago

The current snapshot strategy uses the mementos pattern. Which I think is the cleanest solution. Yet,this can be a strategy as well. It's easy, doesn't need any extra code but it's hard to incompatible snapshots due changes in the entity. But this isn't really a big problem, since you can just throw them away and build again.

Any thoughts?

house9 commented 13 years ago

ok, I think I am understanding this better (maybe?), I just read up on Memento pattern for a basic parent/child relationship, say Project (AR) with many Tasks (Entities) are you saying I would make Task implement ISnapshotable and save that collection under the snapshot of the Project instead of directly saving Task entities in the snapshot?