First off thanks for the compliment.
You need to tell SharpRepository what IoC you are using if you want it to create the DbContext with the Windsor rules you setup. This might be the issue but I’m not sure. Try adding this and seeing if it helps:
RepositoryDependencyResolver.SetDependencyResolver(new WindsorDependencyResolver(container));
It also sounds like it isn’t creating a new IRepository for you each time. I don’t use Windsor, so it’s possible that the logic in the container.RegisterSharpRepository isn’t setup properly.
Here is what it is doing and it should be setup for IRepository to be transient and not a singleton but maybe I implemented it wrong and my understanding of the Windsor container is incorrect.
container.Register(Component.For(typeof(IRepository<>)).UsingFactoryMethod((c, t) =>
{
var genericArgs = t.GenericArguments;
return RepositoryFactory.GetInstance(genericArgs[0], repositoryName);
}));
container.Register(Component.For(typeof(IRepository<,>)).UsingFactoryMethod((c, t) =>
{
var genericArgs = t.GenericArguments;
return RepositoryFactory.GetInstance(genericArgs[0], genericArgs[1], repositoryName);
}));
--
You received this message because you are subscribed to the Google Groups "SharpRepository" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
sharpreposito...@googlegroups.com.
To post to this group, send email to
sharpre...@googlegroups.com.
Visit this group at http://groups.google.com/group/sharprepository.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sharprepository/28163eaf-6bcb-4497-9f1b-3d9e62215020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If that is the default behavior for Windsor then that would explain what is happening. Let me know if that works out and if so it would be great if you could send a pull request for that. I think it is a really nice enhancement.
And that makes me think it would make sense to provide similar overrides for the other IoC extension methods as well in the future.
Thanks.
Jeff
To view this discussion on the web visit https://groups.google.com/d/msgid/sharprepository/17f246c9-617e-4c52-8cf6-fd837dfa2b93%40googlegroups.com.