示例#1
0
        public void BuildingClauseWhenOrderByOrSkipIsNotDefined()
        {
            var data   = new Dictionary <string, string>();
            var result = OffsetClause.Build(new ODataOptions <Model>(data));

            result.Should().BeEmpty();
        }
        public override void ExplicitVisit(OffsetClause node)
        {
            if (node.OffsetExpression.FirstNoneParenthesisExpression() is Literal ||
                node.FetchExpression.FirstNoneParenthesisExpression() is Literal)
            {
                IsSuspected = true;
            }

            base.ExplicitVisit(node);
        }
示例#3
0
        public void BuildingClauseWhenSkipIsDefined()
        {
            var data = new Dictionary <string, string> {
                ["$orderby"] = "Id desc",
                ["$skip"]    = "20"
            };

            var result = OffsetClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("OFFSET 20 ROWS");
        }
示例#4
0
        public void BuildingClauseWhenSkipAndTopAreDefined()
        {
            var data = new Dictionary <string, string> {
                ["$orderby"] = "Id desc",
                ["$skip"]    = "40",
                ["$top"]     = "20"
            };

            var result = OffsetClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("OFFSET 40 ROWS FETCH NEXT 20 ROWS ONLY");
        }
示例#5
0
 public SingleSeriesSelectStatement(
     SelectClause select,
     FromClause from,
     WhereClause where     = null,
     GroupByClause groupBy = null,
     FillClause fill       = null,
     OrderByClause orderBy = null,
     LimitClause limit     = null,
     OffsetClause offset   = null
     )
 {
     Select  = select ?? throw new ArgumentNullException(nameof(select));
     From    = from ?? throw new ArgumentNullException(nameof(from));
     Where   = where;
     GroupBy = groupBy;
     Fill    = fill;
     OrderBy = orderBy;
     Limit   = limit;
     Offset  = offset;
 }
示例#6
0
        public QsiLimitExpressionNode VisitLimitOffset(TopRowFilter topRowFilter, OffsetClause offsetClause)
        {
            return(TreeHelper.Create <QsiLimitExpressionNode>(n =>
            {
                if (topRowFilter != null)
                {
                    var topRowFilterNode = ExpressionVisitor.VisitScalarExpression(topRowFilter.Expression);
                    SqlServerTree.PutFragmentSpan(topRowFilterNode, topRowFilter);

                    n.Limit.SetValue(topRowFilterNode);
                }

                if (offsetClause != null)
                {
                    var offsetClauseNode = ExpressionVisitor.VisitScalarExpression(offsetClause.OffsetExpression);
                    SqlServerTree.PutFragmentSpan(offsetClauseNode, offsetClause);

                    n.Offset.SetValue(offsetClauseNode);
                }
            }));
        }
示例#7
0
 public override void Visit(OffsetClause node) { this.action(node); }
 public override void ExplicitVisit(OffsetClause fragment)
 {
     _fragments.Add(fragment);
 }
示例#9
0
 public override void ExplicitVisit(OffsetClause node)
 {
     IsSuspected = false;
     base.ExplicitVisit(node);
 }