示例#1
0
        public void InnerJoinTest()
        {
            ISqlObject     source0   = new SqlServerSource("Table0");
            ISqlObject     source1   = new SqlServerSource("Table1");
            ISqlObject     id0       = new SqlServerField(source0, "ID", null);
            ISqlObject     id1       = new SqlServerField(source1, "ID", null);
            ISqlExpression condition = id0.Equal(id1);
            SqlFromClause  target    = new SqlFromClause();

            Assert.AreEqual <string>(string.Format("FROM {0} INNER JOIN {1} ON {2}", source0.SqlString, source1.SqlString, condition.SqlString),
                                     target.SetSource(source0).InnerJoin(source1, condition).SqlString);
        }
示例#2
0
        public void InnerJoinTest_Parametric()
        {
            ISqlObject     source0   = new SqlServerSource("Table0");
            ISqlObject     source1   = new SqlServerSource("Table1");
            ISqlObject     id0       = new SqlServerField(source0, "ID", null);
            ISqlObject     id1       = new SqlServerField(source1, "ID", null);
            ISqlExpression value     = SqlStringExpression.FromParameter(new SqlParameter("@p", 13));
            ISqlExpression condition = id0.Equal(id1).And(id0.GreaterEqual(value));
            SqlFromClause  target    = new SqlFromClause();

            Assert.AreEqual <string>(string.Format("FROM {0} INNER JOIN {1} ON {2}", source0.SqlString, source1.SqlString, condition.SqlString),
                                     target.SetSource(source0).InnerJoin(source1, condition).SqlString);
            ReadOnlyCollection <IDataParameter> parameters = target.Parameters;

            Assert.AreEqual <int>(1, parameters.Count);
            Assert.IsTrue(parameters.Contains(value.Parameters[0]));
        }