/// <inheritdoc />
        public async ValueTask Exec(IRwSqlTransaction transaction, CancellationToken cancellationToken)
        {
            var sql =
                @"update posts set author = 'unknown' where author is null;
				  alter table posts alter author set not null"                ;
            await transaction.ExecuteAsync(sql, cancellationToken);
        }
Example #2
0
        public async Task <IActionResult> Post
            ([FromBody] PostDto post, [FromServices] IRwSqlTransaction sqlTransaction, CancellationToken ct)
        {
            var sql = "insert into posts (author, content) values (@author, @content)";
            await sqlTransaction.ExecuteAsync(sql, ct, args : post, affect : SingleRow);

            return(NoContent());
        }
        /// <inheritdoc />
        public async ValueTask Exec(IRwSqlTransaction transaction, CancellationToken cancellationToken)
        {
            var sql = "insert into posts(content) values ('Hello, world!')";
            await transaction.ExecuteAsync(sql, cancellationToken);

            // simulate that migration takes time.
            await Task.Delay(1000, cancellationToken);
        }
Example #4
0
 /// <inheritdoc />
 public async ValueTask Exec(IRwSqlTransaction transaction, CancellationToken cancellationToken)
 {
     var sql = "create table posts(author text, content text not null, timestamp timestamptz default now())";
     await transaction.ExecuteAsync(sql, cancellationToken);
 }