public ICollection <LoadedObjectDataWithDataSourceData> GetOrLoadFetchQueryResult(
            IQuery query,
            LoadedObjectDataPendingRegistrationCollector pendingRegistrationCollector)
        {
            ArgumentUtility.CheckNotNull("query", query);
            ArgumentUtility.CheckNotNull("pendingRegistrationCollector", pendingRegistrationCollector);

            var loadedObjectDataWithSource = _persistenceStrategy.ExecuteFetchQuery(query, LoadedObjectDataProvider).ConvertToCollection();

            var loadedObjectDataAfterConsolidation = LoadedObjectDataRegistrationAgent
                                                     .BeginRegisterIfRequired(
                loadedObjectDataWithSource.Select(data => data.LoadedObjectData),
                true,
                pendingRegistrationCollector)
                                                     .ToList();

            Assertion.IsTrue(loadedObjectDataWithSource.Count == loadedObjectDataAfterConsolidation.Count);
            var loadedObjectDataWithSourceAfterConsolidation = loadedObjectDataWithSource
                                                               .Select((d, i) => new LoadedObjectDataWithDataSourceData(loadedObjectDataAfterConsolidation[i], d.DataSourceData))
                                                               .ConvertToCollection();

            _eagerFetcher.PerformEagerFetching(loadedObjectDataAfterConsolidation, query.EagerFetchQueries, this, pendingRegistrationCollector);

            return(loadedObjectDataWithSourceAfterConsolidation);
        }
        public override ICollection <ILoadedObjectData> GetOrLoadCollectionQueryResult(IQuery query)
        {
            ArgumentUtility.CheckNotNull("query", query);

            var pendingRegistrationCollector = new LoadedObjectDataPendingRegistrationCollector();

            var loadedObjectData = _persistenceStrategy.ExecuteCollectionQuery(query, LoadedObjectDataProvider);

            var loadedObjectDataAfterConsolidation = LoadedObjectDataRegistrationAgent
                                                     .BeginRegisterIfRequired(loadedObjectData, true, pendingRegistrationCollector)
                                                     .ConvertToCollection();

            try
            {
                _eagerFetcher.PerformEagerFetching(loadedObjectDataAfterConsolidation, query.EagerFetchQueries, this, pendingRegistrationCollector);
            }
            finally
            {
                // Even with an exception during eager fetching, go ahead and register everything.
                LoadedObjectDataRegistrationAgent.EndRegisterIfRequired(pendingRegistrationCollector);
            }

            return(loadedObjectDataAfterConsolidation);
        }