コード例 #1
0
        public async Task <int> SubmitCommand(
            PgresUser creds,
            ICommand command)
        {
            using var c   = creds.ToConnection();
            using var cmd = new NpgsqlCommand(
                      command.Sql, c);
            cmd.Parameters.AddMany(command.Parameters);

            await c.OpenAsync();

            var r = await cmd.ExecuteNonQueryAsync();

            return(r);
        }
コード例 #2
0
        public async Task <IEnumerable <T> > Submit <T>(
            PgresUser creds,
            IQuery <T> q)
        {
            using var c   = creds.ToConnection();
            using var cmd = new NpgsqlCommand(q.Sql, c);
            cmd.Parameters.AddMany(q.Parameters);

            IEnumerable <T> r = Enumerable.Empty <T>();
            await c.OpenAsync();

            using var rd = await cmd.ExecuteReaderAsync();

            r = await q.Read(rd);

            return(r);
        }
コード例 #3
0
 public static async Task AssemblyCleanup()
 {
     _dbCreds.Db = "broker_test";
     var dropDb  = _dbCreds.ToConnection(false).DropDatabase(_testDbName);
     var dropDbR = await dropDb.SubmitCommand();
 }