Пример #1
0
        public void TestOrderByMultiple()
        {
            var actual = new OrderByClause()
            {
                OrderExpressions = new List <OrderBy.OrderElement>()
                {
                    new OrderExpression()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        },
                        Ascending = true
                    },
                    new OrderExpression()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c2"
                            }
                        },
                        Ascending = false
                    },
                    new OrderBySubquery()
                    {
                        SelectStatement = new SelectStatement()
                        {
                            SelectElements = new List <SelectExpression>()
                            {
                                new SelectNullExpression()
                            }
                        },
                        Ascending = true
                    },
                    new OrderBySubquery()
                    {
                        SelectStatement = new SelectStatement()
                        {
                            SelectElements = new List <SelectExpression>()
                            {
                                new SelectNullExpression()
                            }
                        },
                        Ascending = false
                    }
                }
            }.Print();
            var expected = "ORDER BY c1 ASC, c2 DESC, (SELECT NULL) ASC, (SELECT NULL) DESC";

            actual.Should().Be(expected);
        }
Пример #2
0
        public void TestOrderBySingle()
        {
            var actual = new OrderByClause()
            {
                OrderExpressions = new List <OrderBy.OrderElement>()
                {
                    new OrderExpression()
                    {
                        Expression = new ColumnReference()
                        {
                            Identifiers = new List <string>()
                            {
                                "c1"
                            }
                        },
                        Ascending = true
                    }
                }
            }.Print();
            var expected = "ORDER BY c1 ASC";

            actual.Should().Be(expected);
        }