You are correct that the GetAll
doesn't actually do anything until you enumerate it in some manner. When you ask for an IEnumerable
, each item pulled brings it to life - even if it's about to be filtered by a Where
(the only way it could is if IQueryable
were involved).
Each item Activated, will be Deactivated in line with the normal scoping rules.
The best way to avoid this is by having a .When... or other condition dictating the filtering.
DO NOT READ PAST THIS POINT - BAD ADVICE FOLLOWS.
A mad Hack is to request an IEnumerable<Lazy<T>>
(which will require Ninject.Extensions.Factory
). Good related article.