Hi, thanks for the library. I appreciate your effort in giving first-class support to asynchronous operations.
I'd like to START TRANSACTION ... READ ONLY. Unfortunately it seems like nothing in MySqlConnection.BeginDbTransactionAsync will append READ ONLY to the START TRANSACTION command.
var isolationLevelValue = isolationLevel switch
{
IsolationLevel.ReadUncommitted => "read uncommitted",
IsolationLevel.ReadCommitted => "read committed",
IsolationLevel.RepeatableRead => "repeatable read",
IsolationLevel.Serializable => "serializable",
IsolationLevel.Snapshot => "repeatable read",
// "In terms of the SQL:1992 transaction isolation levels, the default InnoDB level is REPEATABLE READ." - http://dev.mysql.com/doc/refman/5.7/en/innodb-transaction-model.html
IsolationLevel.Unspecified => "repeatable read",
_ => throw new NotSupportedException("IsolationLevel.{0} is not supported.".FormatInvariant(isolationLevel))
};
using (var cmd = new MySqlCommand($"set session transaction isolation level {isolationLevelValue};", this))
{
await cmd.ExecuteNonQueryAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
var consistentSnapshotText = isolationLevel == IsolationLevel.Snapshot ? " with consistent snapshot" : "";
cmd.CommandText = $"start transaction{consistentSnapshotText};";
await cmd.ExecuteNonQueryAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
}
There's a corresponding READ WRITE option, too. The relevant MySQL documentation is here.
For now I'm eschewing MySqlTransaction in favour of managing it myself with commands.
Hi, thanks for the library. I appreciate your effort in giving first-class support to asynchronous operations.
I'd like to
START TRANSACTION ... READ ONLY. Unfortunately it seems like nothing inMySqlConnection.BeginDbTransactionAsyncwill appendREAD ONLYto theSTART TRANSACTIONcommand.There's a corresponding
READ WRITEoption, too. The relevant MySQL documentation is here.For now I'm eschewing
MySqlTransactionin favour of managing it myself with commands.