What’s the usual way to update a NHibernate entity from a view model?
I have a view model editor where all of my data is displayed, which is fetched via a repository that returns a DTO. The DTO properties are then mapped to my view model properties. I could update my entity if I fetched it again, updated the select property required
Is there a better way?
My usual approach is to have an
EditXViewModelwhich handles change tracking forXViewModeland includes aSaveCommandwhich does the actual entity update. This ensures users can undo changes made without having to remember what they were in the database (it also cuts down on the number of transactions).The following articles were immensely helpful when I started down this same path: