A non-SQL-implementation-specific dataparameter
상속: IDataParameter
예제 #1
0
        public void Clone()
        {
            var item = new WhereItem("field1", "a string");
            var clone = item.Clone();

            Assert.AreEqual(item, clone);
            clone.Value = "something-else";
            Assert.AreNotEqual(item, clone);
            clone.Value = "a string";
            Assert.AreEqual(item, clone);

            var parm = new QueryParameter("someparm", "testvalue");
            var item2 = new WhereString("field2=@someparm or field3='value'", parm);

            var clause = new WhereClause(JoinType.And,item, item2);
            var clone2 = clause.Clone();
            Assert.AreEqual(clause, clone2);
            parm.Value = "testvalue2";
            Assert.AreNotEqual(clause, clone2);
            parm.Value = "testvalue";
            Assert.AreEqual(clause, clone2);

            item.Value = "n";
            Assert.AreNotEqual(clause, clone2);
            item.Value = "a string";
            Assert.AreEqual(clause, clone2);
        }
예제 #2
0
        public void Create()
        {
            var item1 = new WhereItem("field1",123);

            var parm = new QueryParameter("someparm","testvalue");
            var item2 = new WhereString("field2=@someparm",parm);
            var clause = new WhereClause(JoinType.And, item1, item2);

            Assert.AreEqual("field1=@field1 AND (field2=@someparm)", clause.GetSql());

            Assert.AreEqual(2, clause.Parameters.Count());
        }
예제 #3
0
        public void Combine()
        {
            var item1 = new WhereItem("field1", 123);

            var parm = new QueryParameter("someparm", "testvalue");
            var item2 = new WhereString("field2=@someparm or field3='value'", parm);
            var item3 = new WhereItem("field4", 123,parameterize:false);

            var clause = new WhereClause(JoinType.And, item1, item2);

            Assert.AreEqual("field1=@field1 AND (field2=@someparm or field3='value')", clause.GetSql());
            var newClause = clause.Clone();
            newClause.Add(item3,JoinType.Or);
            Assert.AreEqual("(field1=@field1 AND (field2=@someparm or field3='value')) OR field4=123", newClause.GetSql());

            Assert.AreEqual(2, newClause.Parameters.Count());
        }