Exemplo n.º 1
0
        public static IIncludeQuery <TEntity, TNewProperty> Include <TEntity, TPreviousProperty, TNewProperty>
            (this IIncludeQuery <TEntity, TPreviousProperty> query,
            Expression <Func <TEntity, TNewProperty> > selector)
        {
            query.Visitor.Visit(selector);

            var includeQuery = new IncludeQuery <TEntity, TNewProperty>(query.PathMap);

            query.PathMap[includeQuery] = query.Visitor.Path;

            return(includeQuery);
        }
Exemplo n.º 2
0
        public IIncludeQuery <TEntity, TProperty> Include <TProperty>(Expression <Func <TEntity, TProperty> > selector)
        {
            var visitor = new IncludeVisitor();

            visitor.Visit(selector);

            var pathMap = new Dictionary <IIncludeQuery, string>();
            var query   = new IncludeQuery <TEntity, TProperty>(pathMap);

            if (!string.IsNullOrEmpty(visitor.Path))
            {
                pathMap[query] = visitor.Path;
            }

            return(query);
        }
Exemplo n.º 3
0
        public static IIncludeQuery <TEntity, TNewProperty> ThenInclude <TEntity, TPreviousProperty, TNewProperty>(
            this IIncludeQuery <TEntity, IEnumerable <TPreviousProperty> > query,
            Expression <Func <TPreviousProperty, TNewProperty> > selector)
        {
            query.Visitor.Visit(selector);
            if (string.IsNullOrEmpty(query.Visitor.Path))
            {
                return(new IncludeQuery <TEntity, TNewProperty>(query.PathMap));
            }

            var pathMap      = query.PathMap;
            var existingPath = pathMap[query];

            pathMap.Remove(query);

            var includeQuery = new IncludeQuery <TEntity, TNewProperty>(query.PathMap);

            pathMap[includeQuery] = $"{existingPath}.{query.Visitor.Path}";

            return(includeQuery);
        }
Exemplo n.º 4
0
        public static IIncludeQuery <TEntity, TNewProperty> ThenInclude <TEntity, TPreviousProperty, TNewProperty>
            (this IIncludeQuery <TEntity, TPreviousProperty> query, Expression <Func <TPreviousProperty, TNewProperty> > selector)
        {
            query.Visitor.Visit(selector);

            // If the visitor did not generate a path, return a new IncludeQuery with an unmodified PathMap
            if (string.IsNullOrEmpty(query.Visitor.Path))
            {
                return(new IncludeQuery <TEntity, TNewProperty>(query.PathMap));
            }
            var pathMap       = query.PathMap;
            var exisitingPath = pathMap[query];

            pathMap.Remove(query);

            var includeQuery = new IncludeQuery <TEntity, TNewProperty>(query.PathMap);

            pathMap[includeQuery] = $"{exisitingPath}.{query.Visitor.Path}";

            return(includeQuery);
        }