/// <summary>
        /// Creates includes to the query according to the api request fields
        /// </summary>
        /// <typeparam name="T">The type of queried object</typeparam>
        /// <typeparam name="TContext">The type of context</typeparam>
        /// <param name="query">The original query</param>
        /// <param name="context">The data context</param>
        /// <param name="request">The request</param>
        /// <returns>Modified query</returns>
        public static IQueryable <T> SetIncludes <T, TContext>(
            this IQueryable <T> query,
            TContext context,
            ApiRequest request)
            where T : class where TContext : DbContext
        {
            var paths = PathCreator <T, TContext> .CreatePaths(null, context, request).Distinct().ToList();

            var reducedPaths = paths.Where(p => !paths.Any(op => op.StartsWith(p) && op != p)).ToList();

            return(reducedPaths.Aggregate(query, (current, reducedPath) => current.Include(reducedPath)));
        }