Tuesday, September 7, 2010

MongoDB for .NET with NoRM DbReference clarification

In my last post. I mentioned DbReference and how I wasn’t fond that there didn’t appear to be any way to specify that a property was in fact a reference to another document inside an implementation of MongoConfigurationMap. To be fair, this is likely not a common need when dealing with document databases and likely not needed at all for what I’m considering using a document database for, the query piece of CQRS where I will persist a view model directly as it is displayed on the screen so that no translation or multiple reads are needed. Below is a sample of the current API in NoRM for DbReference. Then to retrieve an order and it’s products.

So if you use nHibernate you’re likely seeing the same things that bother me with this API. The class Order is not POCO, and you must explicitly pass a Func<IMongo> in order to load the related products. Ideally I think the API below makes more sense and keeps things cleaner.

Then the query to eager load the related documents.

To be honest I’m not sure how difficult my proposed change would be, but I may take some time to see what it would take regardless of my current needs. I want to understand more of the internals and what a better way to understand than to contribute.

No comments:

Post a Comment