Пример #1
0
 public void TestSelectSentenceBuilder1A()
 {
     var ssb = new SelectStatementBuilder("UserTable", null, new Range(1, 10));
     ssb.Keys.Add(new KeyValuePair<string, string>("a", null));
     const string s = "SELECT TOP 10 [a] FROM [UserTable];\n<Text><60>()";
     Assert.AreEqual(s, ssb.ToSqlStatement(dd, null).ToString());
 }
Пример #2
0
		public void TestSelectSentenceBuilder2()
		{
            var ssb = new SelectStatementBuilder("UserTable", null, new Range(1, 10));
            ssb.Keys.Add(new KeyValuePair<string, string>("a", null));
            ssb.Where.Conditions = new OrClause("ID", 5, 3, 2);
			const string s = "SELECT TOP 10 [a] FROM [UserTable] WHERE ([ID] = @ID_0) OR ([ID] = @ID_1) OR ([ID] = @ID_2);\n<Text><60>(@ID_0=5:Int32,@ID_1=3:Int32,@ID_2=2:Int32)";
            TesterHelper.AssertSqlSentenceEqual(s, ssb.ToSqlStatement(dd, null).ToString());
		}
Пример #3
0
		public void TestSelectSentenceBuilder3()
		{
            var ssb = new SelectStatementBuilder("UserTable", null, new Range(1, 10));
            ssb.Keys.Add(new KeyValuePair<string, string>("a", null));
            ssb.Where.Conditions = new OrClause("ID", 5, 3, 2);
			ssb.Where.Conditions = new AndClause(ssb.Where.Conditions, new KeyValueClause("UserName", "l'lf", CompareOpration.Equal, ColumnFunction.None));
			const string s = "SELECT TOP 10 [a] FROM [UserTable] WHERE (([ID] = @ID_0) OR ([ID] = @ID_1) OR ([ID] = @ID_2)) AND ([UserName] = @UserName_3);\n<Text><60>(@ID_0=5:Int32,@ID_1=3:Int32,@ID_2=2:Int32,@UserName_3=l'lf:String)";
            TesterHelper.AssertSqlSentenceEqual(s, ssb.ToSqlStatement(dd, null).ToString());
		}
Пример #4
0
 public virtual SqlStatement GetGroupByStatement(Condition iwc, OrderBy order, string columnName)
 {
     var builder = new SelectStatementBuilder(Context.Info.From, order, null);
     builder.Where.Conditions = iwc;
     var list = columnName.Split(',');
     foreach (string s in list)
     {
         builder.Keys.Add(new KeyValuePair<string, string>(s, null));
         builder.SetAsGroupBy(s);
     }
     return builder.ToSqlStatement(Context);
 }
Пример #5
0
		public void TestSelectSentenceBuilder0()
		{
			var ssb = new SelectStatementBuilder( "UserTable" );
            ssb.SetCountColumn("*");
			string s = "SELECT COUNT(*) AS it__count__ FROM [UserTable];\n";
			Assert.AreEqual(s, ssb.ToSqlStatement(dd, null).SqlCommandText);

            ssb = new SelectStatementBuilder("UserTable");
            ssb.SetCountColumn("abc");
            s = "SELECT COUNT([abc]) AS it__count__ FROM [UserTable];\n";
            Assert.AreEqual(s, ssb.ToSqlStatement(dd, null).SqlCommandText);

            ssb = new SelectStatementBuilder("UserTable");
            ssb.Keys.Add(new KeyValuePair<string, string>("zzz", null));
            ssb.SetCountColumn("abc");
            s = "SELECT [zzz],COUNT([abc]) AS it__count__ FROM [UserTable];\n";
            Assert.AreEqual(s, ssb.ToSqlStatement(dd, null).SqlCommandText);
        }
Пример #6
0
 public virtual SqlStatement GetSumStatement(Condition iwc, string columnName)
 {
     var builder = new SelectStatementBuilder(this.Context.Info.From, null, null);
     builder.Where.Conditions = iwc;
     builder.SetSumColumn(columnName);
     return builder.ToSqlStatement(this.Context);
 }
Пример #7
0
		public void TestSelectSentenceBuilder1()
		{
			var ssb = new SelectStatementBuilder( "UserTable", null, new Range(1, 10) );
            ssb.ToSqlStatement(dd, null);
		}