I think the point of creating the snapshot of the domain entities/value objects is so that the domain model and data model do not bleed into each other, which is what is bound to happen if you simply use the snapshot as your DTO. The memento pattern on display in this example is the solution to that problem.
I think the dynamic change tracking in EF makes extra requirements on the entity classes you use (all setters/getters must be declared virtual, etc.). I don't think that's being done here.
In fact, to get this example to work, I had to add a SaveChanges() call to the end of the BidHistoryRepository's Add method in order to get the bids saved to the BidHistory table. So, at the end of the IBidHistoryRepository.Add() method, I have this:
// Original last line of the method
_auctionExampleContext.Bids.Add(BidDTO);
// Added line to save the BidDTO to the database
_auctionExampleContext.SaveChanges();
This got the EF example working like the others.
Thank you very much,
Andy
|