Esempio n. 1
0
        public StatementBuilder Pipeline()
        {
            StatementBuilder statement = Cypher.Match(Node).Return(Node);

            if (_filters is not null)
            {
                statement.Match(new Where(_filters), Node);
            }

            if (_projection is not null)
            {
                statement.Return(Node.Project(_projection));
            }

            if (_sorting is null)
            {
                return(statement);
            }

            var sorts = new List <SortItem>();

            foreach (Neo4JSortDefinition sort in _sorting)
            {
                SortItem sortItem = Cypher.Sort(Node.Property(sort.Field));
                if (sort.Direction == SortDirection.Ascending)
                {
                    sorts.Push(sortItem.Ascending());
                }
                else if (sort.Direction == SortDirection.Descending)
                {
                    sorts.Push(sortItem.Descending());
                }
            }

            statement.OrderBy(sorts);

            if (_limit is not null)
            {
                statement.Limit((int)_limit);
            }

            if (_skip is not null)
            {
                statement.Limit((int)_skip);
            }

            return(statement);
        }