The parameter is a terminal expression that is just a specialised IExpression. It was created separately from Expression so that it could store the additional parameters of the field name, table name and parameter type. These are necessary so that the criteria manager component can return a valid SqlExpressionString when required.
The reason for storing this additional info in the expression manager and not parsing it every time a sql statement was required is partly down to performance and partly down to ease of use.
Inheritance: IExpression
コード例 #1
0
 public void TestGetSqlStringWithNoParameters()
 {
     Parameter param = new Parameter("prop", "table", "field", "=", "value", ParameterType.String);
     Assert.AreEqual("", param.GetSqlStringWithNoParameters());
 }
コード例 #2
0
        public void Test_GetParameterValueAsObject_WhenDateType_TomorrowString_ShouldReturnYesterday()
        {
            //---------------Set up test pack-------------------
            Parameter param = new Parameter("prop", "table", "field", "=", "tomorrow", ParameterType.Date);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DateTime parameterValueAsObject = (DateTime)param.GetParameterValueAsObject();
            //---------------Test Result -----------------------
            Assert.IsNotNull(parameterValueAsObject);
            Assert.AreEqual(DateTimeToday.Value.AddDays(1), parameterValueAsObject);
        }
コード例 #3
0
        public void TestParameterConstructors()
        {
            Parameter param = new Parameter("prop", "field", "=", "value");
            Assert.AreEqual("prop = 'value'", param.ExpressionString());
            Assert.AreEqual("[field]", param.FieldFullName("[", "]"));

            param = new Parameter("prop", "table", "field", "=", "value", ParameterType.String);
            Assert.AreEqual("prop = 'value'", param.ExpressionString());
            Assert.AreEqual("[table].[field]", param.FieldFullName("[", "]"));
        }
コード例 #4
0
        public void TestParameterTypes()
        {
            Parameter param = new Parameter("prop", "table", "field", "=", "value", ParameterType.String);
            Assert.AreEqual("value", param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "true", ParameterType.Bool);
            Assert.AreEqual(true, param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "2007/2/1", ParameterType.Date);
            Assert.AreEqual(new DateTime(2007, 2, 1), param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "2.1", ParameterType.Number);
            Assert.AreEqual(2.1, param.GetParameterValueAsObject());
        }
コード例 #5
0
 public void TestParameterParsing()
 {
     IExpression exp = new Parameter("Field1 = 'test'");
     Assert.AreEqual("Field1 = 'test'", exp.ExpressionString());
 }