Пример #1
0
        public void FromVariableTest()
        {
            string     variable = "@@error";
            ISqlObject obj      = SqlObject.FromVariable(variable);

            Assert.AreEqual <string>(variable, obj.Fullname);
            Assert.AreEqual <string>(variable, obj.SqlString);
        }
Пример #2
0
        public void SqlStringTest_Expression()
        {
            ISqlObject      source     = new SqlServerSource("Table");
            ISqlExpression  expression = new SqlFunction("MAX").AddArgument(new SqlServerField(source, "ID", null));
            ISqlObject      field      = SqlObject.FromVariable("ROWNUM");
            ISqlGroupClause target     = new SqlGroupClause().AddExpressions(expression, field);

            Assert.AreEqual <string>(string.Format("{0} {1}, {2}", target.Keyword, expression.SqlString, field.Fullname), target.SqlString);
        }
Пример #3
0
        public void SqlStringTest_More()
        {
            ISqlObject      source = new SqlServerSource("Table");
            ISqlObject      field0 = new SqlServerField(source, "Field0", null);
            ISqlObject      field1 = SqlObject.FromVariable("ROWNUM");
            ISqlGroupClause target = new SqlGroupClause().AddExpressions(field0, field1);

            Assert.AreEqual <string>(string.Format("{0} {1}, {2}", target.Keyword, field0.Fullname, field1.Fullname), target.SqlString);
        }
Пример #4
0
        public void SqlStringTest_More()
        {
            ISqlObject      source = new SqlServerSource("Table");
            ISqlObject      field0 = new SqlServerField(source, "AddTime", null);
            ISqlObject      field1 = SqlObject.FromVariable("ROWNUM");
            ISqlOrderClause target = new SqlOrderClause().AddExpression(field0, SqlOrder.Desc).AddExpression(field1, SqlOrder.Asc);

            Assert.AreEqual <string>(string.Format("{0} ({1}) DESC, ({2}) ASC", target.Keyword, field0.Fullname, field1.Fullname), target.SqlString);
        }
        public void CountTest()
        {
            ISqlObject            source = new OracleSource("Table");
            ISqlObject            field  = new OracleField(source, "ID");
            OracleSelectStatement target = new OracleSelectStatement();

            target.SelectClause.AddExpressions(field);
            target.FromClause.Source     = source;
            target.WhereClause.Condition = field.GreaterThan(new SqlStringExpression("13"));
            target.OrderClause.AddExpression(field, SqlOrder.Desc);
            string sqlString = target.SqlString;

            target.Count = 13;
            ISqlObject rowNumber = SqlObject.FromVariable("ROWNUM");

            Assert.AreEqual <string>(string.Format("SELECT * FROM ({1}) {0} WHERE {2} ORDER BY {3} ASC", new OracleSource(OracleSelectStatement.MIDDLE_RESULT_NAME), sqlString, rowNumber.GreaterEqual(new SqlStringExpression(target.Count.ToString())), rowNumber.Fullname),
                                     target.SqlString);
        }