MongoDB C# connections/disconnections (Official driver)
Please tell me how I must connect/disconnect to MongoDB via official C# driver? Question is simple and problem is trivial for first look, but:
1) Do I need to call Disconnect method by myself, or it will be closed by some method like Dispose?
2) Do I need to Connect every time when I need to make request to Mongo? Or it will be better to keep Connection?
3) Is method Reconnect are useful? Do you use it?
Any additional advice?
Thank you very much!!!
Update: My question is about the life cycle of connections开发者_StackOverflow社区;)
The official driver maintains a connection pool internally. You do not need to dispose of any connections or even establish new connections.
Requesting a connection is as easy as this
MongoServer.Create(mongoConnectionString)
Read more at the doc site for the driver.
精彩评论