/// <summary> /// Eagerly fetches a collection of 'grandchild' objects from child object(s) which have themselves been fetched. /// </summary> /// <returns>An object equivalent to the original query.</returns> /// <param name="query">A query in which a child object or collection of objects has been fetched.</param> /// <param name="getterExpression">An expression indicating the collection of grandchild objects to be fetched.</param> /// <typeparam name="TQueried">The queried type.</typeparam> /// <typeparam name="TChild">The type of the child object which has been fetched.</typeparam> /// <typeparam name="TGrandchild">The type of the grandchild objects which are to be fetched.</typeparam> public IQueryableWithEagerFetching <TQueried, TGrandchild> FetchGrandchildren <TQueried, TChild, TGrandchild>(IQueryableWithEagerFetching <TQueried, TChild> query, Expression <Func <TChild, IEnumerable <TGrandchild> > > getterExpression) { return(new NoOpEagerFetchQueryableAdapter <TQueried, TGrandchild>(query)); }
/// <summary> /// Eagerly fetches a collection of 'grandchild' objects from child object(s) which have themselves been fetched. /// </summary> /// <returns>An object equivalent to the original query.</returns> /// <param name="query">A query in which a child object or collection of objects has been fetched.</param> /// <param name="getterExpression">An expression indicating the collection of grandchild objects to be fetched.</param> /// <typeparam name="TQueried">The queried type.</typeparam> /// <typeparam name="TChild">The type of the child object which has been fetched.</typeparam> /// <typeparam name="TGrandchild">The type of the grandchild objects which are to be fetched.</typeparam> public IQueryableWithEagerFetching <TQueried, TGrandchild> FetchGrandchildren <TQueried, TChild, TGrandchild>(IQueryableWithEagerFetching <TQueried, TChild> query, Expression <Func <TChild, IEnumerable <TGrandchild> > > getterExpression) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (!(query.Provider is NhQueryProvider)) { throw new ArgumentException($"The query provider must be an instance of {typeof(NhQueryProvider).FullName}.", nameof(query)); } var queryToUse = GetNhFetchRequest <TQueried, TChild>(query); var nhFetchRequest = EagerFetchingExtensionMethods.ThenFetchMany(queryToUse, getterExpression); return(new QueryableWithFetchingAdapter <TQueried, TGrandchild>(nhFetchRequest)); }