Esempio n. 1
0
        public void ToString_AllProperties()
        {
            var dataInfo         = new TestStreamedValueInfo(typeof(int));
            var selectProjection = Expression.Constant(1);
            var sqlTable1        = new SqlTable(new ResolvedSimpleTableInfo(typeof(Cook), "CookTable", "c"), JoinSemantics.Inner);
            var sqlTable2        = new SqlTable(new ResolvedSimpleTableInfo(typeof(Kitchen), "KitchenTable", "k"), JoinSemantics.Left);
            var ordering         = new Ordering(Expression.Constant("ordering"), OrderingDirection.Asc);
            var whereCondition   = Expression.Constant(true);
            var topExpression    = Expression.Constant(10);
            var groupExpression  = Expression.Constant("group");

            var builder = new SqlStatementBuilder
            {
                DataInfo          = dataInfo,
                SelectProjection  = selectProjection,
                SqlTables         = { sqlTable1, sqlTable2 },
                Orderings         = { ordering },
                WhereCondition    = whereCondition,
                TopExpression     = topExpression,
                IsDistinctQuery   = true,
                GroupByExpression = groupExpression
            };

            var result = builder.ToString();

            Assert.That(
                result,
                Is.EqualTo(
                    "SELECT DISTINCT TOP (10) 1 FROM [CookTable] [c], [KitchenTable] [k] WHERE True GROUP BY \"group\" ORDER BY \"ordering\" ASC"));
        }
Esempio n. 2
0
        public void ToString_NoProperties()
        {
            var builder = new SqlStatementBuilder();

            var result = builder.ToString();

            Assert.That(result, Is.EqualTo("SELECT "));
        }
Esempio n. 3
0
        public void ToString_SingleTable()
        {
            var dataInfo         = new TestStreamedValueInfo(typeof(int));
            var selectProjection = Expression.Constant(1);
            var sqlTable         = new SqlTable(new ResolvedSimpleTableInfo(typeof(Cook), "CookTable", "c"), JoinSemantics.Inner);

            var builder = new SqlStatementBuilder
            {
                DataInfo         = dataInfo,
                SelectProjection = selectProjection,
                SqlTables        = { sqlTable },
            };

            var result = builder.ToString();

            Assert.That(result, Is.EqualTo("SELECT 1 FROM [CookTable] [c]"));
        }