コード例 #1
0
        public void WhereWithMoreColumns()
        {
            string sqlTest = "select * from table";

            SelectBuilder select = new SelectBuilder(sqlTest);

            select.AddCondition("column1 = :column1");
            select.AddCondition("column2 = :column2");

            Assert.IsTrue(select.SelectStatement.Contains("where"));
            Assert.IsTrue(select.SelectStatement.Contains("column1 = :column1"));
            Assert.IsTrue(select.SelectStatement.Contains("and column2 = :column2"));
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: Kapitany777/SqlBuilder
        private void buttonGetSqlStatement_Click(object sender, EventArgs e)
        {
            SelectBuilder selectBuilder = new SelectBuilder(@"select * from table");

            selectBuilder.AddCondition("column1 = :column1");

            selectBuilder.AddCondition(textBox1, "column2 = :column2");
            selectBuilder.AddCondition(textBox2, "column3 = :column3");

            selectBuilder.AddCondition(checkBox1, "column4 = :column4");
            selectBuilder.AddCondition(checkBox2, "column5 = :column5");

            selectBuilder.AddOrderBy("column1, column2");

            textBoxSqlStatement.Text = selectBuilder.SelectStatement;
        }
コード例 #3
0
        public void WhereWithEmptyTextBox()
        {
            string sqlTest = "select * from table";

            TextBox textBox = new TextBox();

            textBox.Text = string.Empty;

            SelectBuilder select = new SelectBuilder(sqlTest);

            select.AddCondition(textBox, "column1 = :column1");

            Assert.IsFalse(select.SelectStatement.Contains("where"));
            Assert.IsFalse(select.SelectStatement.Contains("column1 = :column1"));
        }
コード例 #4
0
        public void WhereWithUncheckedCheckBox()
        {
            string sqlTest = "select * from table";

            CheckBox checkBox = new CheckBox();

            checkBox.Checked = false;

            SelectBuilder select = new SelectBuilder(sqlTest);

            select.AddCondition(checkBox, "column1 = :column1");

            Assert.IsFalse(select.SelectStatement.Contains("where"));
            Assert.IsFalse(select.SelectStatement.Contains("column1 = :column1"));
        }