예제 #1
0
파일: Support.cs 프로젝트: stazz/CBAM
 public static async Task AddJSONSupportAsync(this PgSQLConnection connection)
 {
     // TODO detect if we already added support...
     await connection.TypeRegistry.AddTypeFunctionalitiesAsync(
         ("json", CreateJSONSupport),
         ("jsonb", CreateJSONBSupport)
         );
 }
예제 #2
0
        protected static async Task AssertThatQueryProducesSameResults(PgSQLConnection connection, String query, params Object[] values)
        {
            var queryCount = 0;
            await connection.PrepareStatementForExecution(query).EnumerateAsync(async item =>
            {
                Assert.AreEqual(values[queryCount++], await((SQLDataRow)item).GetValueAsObjectAsync(0));
            });

            Assert.AreEqual(values.Length, queryCount);
        }
예제 #3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            cmds[0] = tbQuery1.Text;
            cmds[1] = tbQuery2.Text;

            if (rbMySQL.Checked == true)
            {
                MySQLConnection MySQLCon = new MySQLConnection();

                MySQLCon.MySQLServer = tbServidor.Text;
                MySQLCon.MySQLPort   = tbPort.Text;
                MySQLCon.MySQLUser   = tbUser.Text;
                MySQLCon.MySQLPass   = tbPass.Text;

                MySQLCon.TransacaoMySQL(cmds);
            }
            else if (rbMSSQL.Checked == true)
            {
                MSSQLConnection MSSQLCon = new MSSQLConnection();

                MSSQLCon.MSSQLServer = tbServidor.Text;
                MSSQLCon.MSSQLPort   = tbPort.Text;
                MSSQLCon.MSSQLUser   = tbUser.Text;
                MSSQLCon.MSSQLPass   = tbPass.Text;

                MSSQLCon.TransacaoMSSQL(cmds);
            }
            else if (rbPgSQL.Checked == true)
            {
                PgSQLConnection PgSQLCon = new PgSQLConnection();

                PgSQLCon.PgSQLServer = tbServidor.Text;
                PgSQLCon.PgSQLPort   = tbPort.Text;
                PgSQLCon.PgSQLUser   = tbUser.Text;
                PgSQLCon.PgSQLPass   = tbPass.Text;

                PgSQLCon.TransacaoPgSQL(cmds);
            }
            else if (rbFirebird.Checked == true)
            {
                FirebirdConnection FirebirdCon = new FirebirdConnection();

                FirebirdCon.FirebirdServer = tbServidor.Text;
                FirebirdCon.FirebirdPort   = tbPort.Text;
                FirebirdCon.FirebirdUser   = tbUser.Text;
                FirebirdCon.FirebirdPass   = tbPass.Text;

                FirebirdCon.TransacaoFirebird(cmds);
            }
            else
            {
                MessageBox.Show("ERRO");
            }
        }
예제 #4
0
        protected static async Task AssertThatQueryProducesSameResults_IgnoreOrder(PgSQLConnection connection, String query, params Object[] values)
        {
            var valuesSet  = new HashSet <Object>(values);
            var querySet   = new HashSet <Object>();
            var queryCount = 0;
            await connection.PrepareStatementForExecution(query).EnumerateAsync(async item =>
            {
                querySet.Add(await((SQLDataRow)item).GetValueAsObjectAsync(0));
                ++queryCount;
            });

            Assert.AreEqual(values.Length, queryCount);
            Assert.IsTrue(valuesSet.SetEquals(querySet));
        }
예제 #5
0
        protected static async Task AssertThatConnectionIsStillUseable(PgSQLConnection connection)
        {
            var selectResult = await connection.GetFirstOrDefaultAsync <Int32>("SELECT 1");

            Assert.AreEqual(1, selectResult);
        }