When using MySql.Data version 8.0.31 with .Net 6.0, when the isolation level is set for a command, the command is executed at the default isolation level.
The sample below demonstrates the issue:
[TestMethod]
public void TestBuggyIso()
{
var connection = new MySqlConnection(ConnectionString);
connection.Open();
var transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable);
MySqlCommand command = new("SELECT @@transaction_isolation;", connection, transaction);
var reader = command.ExecuteReader();
while (reader.Read())
{
string value = reader.GetString(0);
Assert.AreEqual(value, "SERIALIZABLE");
}
}
Here the isolation level should be Serializable but I see that the isolation level is set to REPEATABLE-READ.
The sample below demonstrates the issue:
[TestMethod]
public void TestBuggyIso()
{
var connection = new MySqlConnection(ConnectionString);
connection.Open();
var transaction = connection.BeginTransaction(System.Data.IsolationLevel.Serializable);
MySqlCommand command = new("SELECT @@transaction_isolation;", connection, transaction);
var reader = command.ExecuteReader();
while (reader.Read())
{
string value = reader.GetString(0);
Assert.AreEqual(value, "SERIALIZABLE");
}
}
Here the isolation level should be Serializable but I see that the isolation level is set to REPEATABLE-READ.