Detached objects are disconnected = the context does not know about them and cannot track its changes. You cannot go through your ObjectSets - it will load your entire database into your application! If you want to know the state of your objects that are tracked by context, use:
var entries = context.ObjectStateManager.GetObjectStateEntries(~EntityState.Detached);
This will lead to your ObjectStateEntry collection, where each record represents a single tracked entity or independent association.
source share