MongoDB C# mapping domain objects
Normally when using Nhibernate I have models in the Nhibernate project, then they are mapped to a UI model to be used and then back, however I have to use merge frequently opposed to update because the mapped model although having the same Id as an existing NhibernateModel it isnt the same object.
On my next project I know MongoDB is going to be the database so I am just wondering if there would be any issues when mapping from UI to Mongo objects? A scenario would be:
- User creates an account
- The account is persisted in Mongo
- The user开发者_StackOverflow社区 views the account details (a call to mongo, then a map to a UI model)
- The user changes their date of birth
- The user saves their changed account (a map to a mongo model, then a call to mongo to update)
Hopefully this will be a simple answer!
One issue you might want to consider with Mongo is that it can accept an update document containing just the few fields you want to change, so instead of saving the entire object back you may end up making separate calls to update individual components of it.
This feature is particularly useful in an AJAX powered application where you have lots of small updates to make. For example, on page load you might fire of a single update to set the user's LastAccessed date, when the click an element in the UI you might update a single field on their record, ...
If you want to use it in a more traditional ORM style you can do that (albeit without the change tracking features you might be used to) but it's worth considering this alternate style.
精彩评论