3

How to store poco c# objects using MongoDB .net driver? The custom attributes and ObjectId methods are intrusive and require changes to the domain classes introducing coupling with mongodb. Are there well documented methods to use POCO classes with MongoDB? Also any integration with SpringFramework.net.

1
  • Well you could use DTOs between your business layer and DAL, which have the required ID. But it sounds worse than creating an ID field in your objects, which isn't pretty bad. Commented Jul 8, 2015 at 3:19

1 Answer 1

1

The documentation (http://mongodb.github.io/mongo-csharp-driver/2.0/reference/bson/mapping/) has many examples. Anything you can do with attributes can be done via code as well.

Regarding the ObjectId, I'd suggest using a string and indicating(via code) that it should be stored as an ObjectId in the database. Alternatively, just use a Guid.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.