Code: Select all
public static void PrintIsolationLevel(string connectionString)
{
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions{IsolationLevel = IsolationLevel.ReadUncommitted}))
using (var connection = new MySqlConnection(connectionString))
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SHOW VARIABLES LIKE 'tx_isolation';";
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var level = reader.GetString(1);
Console.WriteLine("TransactionScope Isolation level {0}",Transaction.Current.IsolationLevel);
Console.WriteLine("Database isolation level {0}", level);
}
}
}
}
}
Code: Select all
TransactionScope Isolation level ReadUncommitted
Database isolation level REPEATABLE-READ
Code: Select all
TransactionScope Isolation level ReadUncommitted
Database isolation level READ-UNCOMMITTED
Any ideas?