예제 #1
0
        public override SqlStatement TransformStatement(SqlStatement statement)
        {
            // SQL Server 2012 supports OFFSET/FETCH providing there is an ORDER BY
            // UPDATE queries do not directly support ORDER BY, TOP, OFFSET, or FETCH, but they are supported in subqueries

            if (statement.IsUpdate() || statement.IsDelete())
            {
                statement = WrapRootTakeSkipOrderBy(statement);
            }
            statement = AddOrderByForSkip(statement);

            return(statement);
        }
예제 #2
0
        public override SqlStatement TransformStatement(SqlStatement statement)
        {
            //SQL Server 2008 supports ROW_NUMBER but not OFFSET/FETCH

            statement = SeparateDistinctFromPagination(statement, q => q.Select.TakeValue != null || q.Select.SkipValue != null);
            if (statement.IsUpdate() || statement.IsDelete())
            {
                statement = WrapRootTakeSkipOrderBy(statement);
            }
            statement = ReplaceSkipWithRowNumber(statement);

            return(statement);
        }
예제 #3
0
        public override SqlStatement TransformStatement(SqlStatement statement)
        {
            if (statement.IsUpdate() || statement.IsInsert() || statement.IsDelete())
            {
                statement = ReplaceTakeSkipWithRowNum(statement, false);
            }

            switch (statement.QueryType)
            {
            case QueryType.Delete: statement = GetAlternativeDelete((SqlDeleteStatement)statement); break;

            case QueryType.Update: statement = GetAlternativeUpdate((SqlUpdateStatement)statement); break;
            }

            return(statement);
        }
예제 #4
0
        public override SqlStatement TransformStatement(SqlStatement statement)
        {
            //SQL Server 2008 supports ROW_NUMBER but not OFFSET/FETCH

            statement = SeparateDistinctFromPagination(statement, q => q.Select.TakeValue != null || q.Select.SkipValue != null);
            if (statement.IsUpdate() || statement.IsDelete())
            {
                statement = WrapRootTakeSkipOrderBy(statement);
            }
            statement = ReplaceSkipWithRowNumber(statement);
            if (statement.QueryType == QueryType.Select)
            {
                statement = QueryHelper.OptimizeSubqueries(statement);                 // OptimizeSubqueries can break update queries
            }
            return(statement);
        }