What’s wrong with the following code?
using (var transaction = session.BeginTransaction()) { session.Save(something); transaction .Commit(); }
Nothing if you are using MySQL connector 6.0, which has the following Dispose method on its MySqlTransaction class.
protected override void Dispose(bool disposing) { if ((((this.conn != null) && (this.conn.State == ConnectionState.Open)) || this.conn.SoftClosed) && this.open) { this.Rollback(); } base.Dispose(disposing); }
But if you are using 5.0.9, check out this code (which is actually from the underlying DbTransaction object).
public void Dispose() { this.Dispose(true); } protected virtual void Dispose(bool disposing) { }
Where’s the rollback? Missing. Just wait till your next transaction block.
Looks like it was fixed in 5.1. Srijak and Dellanoce figured this out, but I sniped it from them before they could post. I was standing over their shoulder :)
Backing up a SQL Server database and restoring it to another server is a common operation done for reporting, testing, or development. When restoring on a different machine, a common problem is the login principals don’t actually correlate to the restored database users. This is because they are linked by an SID. This SID isn’t the user name, its some hash value, probably a GUID. The problem is fully described in this