I'm currently writing a piece of code that does some searches which returns IDisposable objects (DirectoryEntry to be specific from an ADAM instance) and I end up with code similar to
using(var entry = (from result in results
let entry = result.GetDirectoryEntry()
where entry != null
select entry).Last())
{
//blah blah
}
but who is then responsible for Disposing the objects not returned by the above query? or more to the point is the above code actually missing a call to Dispose() for all other entries than the last?