public static IQueryable <T> ApplyFetchingOptions <T>(this IQueryable <T> query, IRepositoryConventions conventions, IFetchQueryStrategy <T> fetchStrategy) where T : class
        {
            Guard.NotNull(query, nameof(query));
            Guard.NotNull(conventions, nameof(conventions));

            var fetchingPaths = fetchStrategy.DefaultIfFetchStrategyEmpty(conventions).PropertyPaths.ToList();

            if (fetchingPaths.Any())
            {
                query = fetchingPaths.Aggregate(query, (current, path) => current.Include(path));
            }

            return(query);
        }
        /// <summary>
        /// Apply a fetching options to the specified entity's query.
        /// </summary>
        /// <returns>The entity's query with the applied options.</returns>
        public static IEnumerable <T> ApplyFetchingOptions <T>([NotNull] this IEnumerable <T> query, [CanBeNull] IFetchQueryStrategy <T> fetchStrategy, [NotNull] Func <Type, IEnumerable <object> > innerQueryCallback) where T : class
        {
            Guard.NotNull(query, nameof(query));
            Guard.NotNull(innerQueryCallback, nameof(innerQueryCallback));

            var fetchingPaths = fetchStrategy.DefaultIfFetchStrategyEmpty().PropertyPaths.ToList();
            var fetchHelper   = new FetchHelper(innerQueryCallback);

            if (fetchingPaths.Any())
            {
                query = fetchingPaths.NormalizePropertyPaths().Aggregate(query, (current, path) => fetchHelper.Include(current, path));
            }

            return(query);
        }
 /// <summary>
 /// Returns the fetch strategy, or a default valued if the sequence is empty.
 /// </summary>
 /// <typeparam name="T">The type of the entity.</typeparam>
 /// <param name="source">The source.</param>
 /// <returns>The fetching strategy.</returns>
 public static IFetchQueryStrategy <T> DefaultIfFetchStrategyEmpty <T>([CanBeNull] this IFetchQueryStrategy <T> source)
 {
     return(source.DefaultIfFetchStrategyEmpty(RepositoryConventions.Default()));
 }