I\'m not quite sure when I should use SingletonScope() vs TransientScope() vs RequestScope() when I do my binding in my global.cs file.
I have for example my call to
I guess the answer would depend on whether your MongoSession
represents a unit of work or not. Most database related classes that I've worked with (mostly in the context of ORM, such as NHibernate or EF4) revolve around a context, entities, and tracked state that represent a unit of work. A unit of work should never be kept around longer than the length of time required to perform the given unit of work, after which the unit should be committed or rolled back. That would mean you should use RequestScope
.
If your MongoSession
is not a unit of work, you could keep it around for the lifetime of an MVC session, in which case SessionScope
would then be appropriate.