public void TestUpdateQueryBuilder2() { IDictionary <string, object> param = new Dictionary <string, object>(); param.Add(@"COLUMN1", 1); param.Add(@"COLUMN2", @"ABC"); string tbl = @"TableName"; object[] whereParam = { 2, @"DEF" }; string where = @"COLUMN3=? AND COLUMN4=?"; string exp = @"UPDATE TableName SET COLUMN1=@__param_0,COLUMN2=@__param_1 WHERE COLUMN3=@__param_2 AND COLUMN4=@__param_3"; UpdateQueryBuilder b = new UpdateQueryBuilder(tbl); b.SetParams(param); b.SetWhere(where, whereParam); using (SqlConnection conn = new SqlConnection()) using (DbCommand result = b.Result(conn, UpdateType.UPDATE)) { Assert.AreEqual(exp, result.CommandText); Assert.AreEqual(1, result.Parameters[0].Value); Assert.AreEqual(@"ABC", result.Parameters[1].Value); Assert.AreEqual(2, result.Parameters[2].Value); Assert.AreEqual(@"DEF", result.Parameters[3].Value); } }
public void TestUpdateQueryBuilder3() { string tbl = @"TableName"; string exp = @"INSERT INTO TableName (COLUMN1,COLUMN2) VALUES (@__param_0,@__param_1)"; UpdateQueryBuilder b = new UpdateQueryBuilder(tbl); UpdatePabo pabo = new UpdatePabo(); b.SetParams(ObjectQuery.GetParams(pabo)); using (SqlConnection conn = new SqlConnection()) using (DbCommand result = b.Result(conn, UpdateType.INSERT)) { Assert.AreEqual(exp, result.CommandText); Assert.AreEqual(pabo.Num, result.Parameters[0].Value); Assert.AreEqual(pabo.S, result.Parameters[1].Value); } }
public void TestUpdateQueryBuilder1() { IDictionary <string, object> param = new Dictionary <string, object>(); param.Add(@"COLUMN1", 1); param.Add(@"COLUMN2", @"ABC"); string tbl = @"TableName"; string exp = @"INSERT INTO TableName (COLUMN1,COLUMN2) VALUES (@__param_0,@__param_1)"; UpdateQueryBuilder b = new UpdateQueryBuilder(tbl); b.SetParams(param); using (SqlConnection conn = new SqlConnection()) using (DbCommand result = b.Result(conn, UpdateType.INSERT)) { Assert.AreEqual(exp, result.CommandText); Assert.AreEqual(1, result.Parameters[0].Value); Assert.AreEqual(@"ABC", result.Parameters[1].Value); } }