Aug 1, 2014 at 3:45 PM
Edited Aug 1, 2014 at 3:47 PM
I am creating an object of the interface through registerinstance in unity.config file in my MVC project which runs when the application starts.
ConnectionRepository connectionRepository = new ConnectionRepository();
unityContainer.RegisterInstance(typeof (IConnectionRepository), connectionRepository);
And in my other classes I getting the instance of the object as this and this class is called for each user that logs in:
IConnectionRepository connectionRepository =
DependencyResolver.Current.GetService(typeof (IConnectionRepository)) as ConnectionRepository;
ConnectionRepository has a connectionstring parameter whose value is user specific.
I mean when user 'A' logs in the connection string should be 'x' and user 'B' it should be 'y'.
My question is whenever a call to 'DependencyResolver.Current.GetService(typeof (IConnectionRepository))' for each user creates a new instance of connection repository class or its going to be a single instance for the whole application?
Because if it is single instance for the whole application its going to be a problem because the connection string value changes between users i.e when the code accessing connectionstring for user 'A' it will have user 'B' connection string and cause an unexpected