Skip to content

Instantly share code, notes, and snippets.

@danmalcolm
Last active December 10, 2015 21:48
Show Gist options
  • Save danmalcolm/4497258 to your computer and use it in GitHub Desktop.
Save danmalcolm/4497258 to your computer and use it in GitHub Desktop.
Example of resetting database by executing a simple SQL script
const string ResetSql = @"delete from a
delete from b
...
delete from m";
// Removes any data generated by tests from the database
private void ResetDatabase()
{
InUnitOfWork(session =>
{
var command = session.Connection.CreateCommand();
command.CommandText = ResetSql;
session.Transaction.Enlist(command);
command.ExecuteNonQuery();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment