BuildOrderByPart() public method

public BuildOrderByPart ( SqlStatement sqlStatement, ISqlCommandBuilder commandBuilder ) : void
sqlStatement Remotion.Linq.SqlBackend.SqlStatementModel.SqlStatement
commandBuilder ISqlCommandBuilder
return void
Ejemplo n.º 1
0
        public void BuildOrderBy_WithSingleOrderByClause()
        {
            var columnExpression = new SqlColumnDefinitionExpression(typeof(string), "t", "Name", false);
            var orderByClause    = new Ordering(columnExpression, OrderingDirection.Asc);

            var sqlStatement = new SqlStatement(
                new TestStreamedValueInfo(typeof(int)),
                _entityExpression,
                new[] { _sqlTable },
                null,
                null,
                new[] { orderByClause },
                null,
                false,
                null,
                null);

            _stageMock.Expect(mock => mock.GenerateTextForOrdering(_commandBuilder, orderByClause))
            .WhenCalled(mi => ((SqlCommandBuilder)mi.Arguments[0]).Append("[t].[Name] ASC"));
            _stageMock.Replay();

            _generator.BuildOrderByPart(sqlStatement, _commandBuilder);

            Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo(" ORDER BY [t].[Name] ASC"));
            _stageMock.VerifyAllExpectations();
        }
Ejemplo n.º 2
0
        public void BuildOrderBy_WithSingleOrderByClause()
        {
            var columnExpression = new SqlColumnDefinitionExpression(typeof(string), "t", "Name", false);
            var orderByClause    = new Ordering(columnExpression, OrderingDirection.Asc);

            var sqlStatement = SqlStatementModelObjectMother.CreateMinimalSqlStatement(new SqlStatementBuilder {
                Orderings = { orderByClause }
            });

            _stageMock.Expect(mock => mock.GenerateTextForOrdering(_commandBuilder, orderByClause))
            .WhenCalled(mi => ((SqlCommandBuilder)mi.Arguments[0]).Append("[t].[Name] ASC"));
            _stageMock.Replay();

            _generator.BuildOrderByPart(sqlStatement, _commandBuilder);

            Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo(" ORDER BY [t].[Name] ASC"));
            _stageMock.VerifyAllExpectations();
        }