MySql-事务

事务支持

基本用法:

string connString = "Your connection string";
using (MySqlContext context = new MySqlContext(new MySqlConnectionFactory(connString)))
{
    context.Session.BeginTransaction();
    try
    {
        /* do some things here */
        context.Update(user);
        context.Delete<User>(a => a.Gender == null);

        context.Session.CommitTransaction();
    }
    catch
    {
        if (context.Session.IsInTransaction)
            context.Session.RollbackTransaction();
        throw;
    }
}