c# - When to use Singleton vs Transient vs Request using Ninject and MongoDB -


I do not believe that when I create a Singlesonscope () versus TransactionShop () vs. Config Scope (), my global cc file In.

For example, I have a Mongo session (using the NORM and MVTstarter project) which is set to the singletascope but I have created a repository that uses this MongoSession object to call Mongo easy For example, I have a news repository that uses MongoSession to fetch my news items from the data, as an example, I have a call that is available for news items. Rdrshit does that DisplayOnHome is set on the right and has the latest by Kriasndet. Can such a repository singlescapes be possible or will RequestScope be more appropriate?

How should I use it and why?

In a web app in general, you want the state to make the scope of the request as much as possible .

In case of only very low level adaptation, do you ever go to a case where appropriate for creating a single object (and then it is likely that you have such caching / shared logic in the second category Which are drawn as dependents on your second [request area] objects and that singleton area). Remember that in the context of the web app, a singleton means many threads using the same object. This is rarely the good news.

On the same basis, the transient scope is the most straightforward default (and that is why ning 2) makes such a - the request scope should only come in the equation when some require sharing, Etc. (or because it is only a reference to sharing [as mentioned in the second answer]).


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -