You can solve this problem by moving Decoraptor between the filter and the repository.
Without knowing much about your code, you should be able to define a Decoraptorepository using Abstract Factory:
public class Decoraptorepository : IRepository { private readonly IFactory<IRepository> factory; public Decoraptorepository(IFactory<IRepository> factory) { this.factory = factory; }
This allows your filter to remain Singleton, while the actual repository is created in Transient mode.
If you also need to delete objects, see the next article on how to decompose Transient objects from within Decoraptor .
Mark seemann
source share