Skip to content

Instantly share code, notes, and snippets.

@brendanjerwin
Created March 12, 2009 01:58
Show Gist options
  • Save brendanjerwin/77865 to your computer and use it in GitHub Desktop.
Save brendanjerwin/77865 to your computer and use it in GitHub Desktop.
An example of using the Configuration class with an In-Memory SQLite DB
[TestFixtureSetUp]
public void FixtureSetUp()
{
Configuration cfg;
Models.Data.Util.Configuration.ConfigureDataAccess(SQLiteConfiguration.Standard.InMemory(),
InstanceScope.Singleton, out cfg);
session = ObjectFactory.GetInstance<ISession>();
IDbConnection connection = session.Connection;
Dialect _dialect = Dialect.GetDialect(cfg.Properties);
string[] drops = cfg.GenerateDropSchemaScript(_dialect);
ExecuteScripts(drops, connection);
string[] scripts = cfg.GenerateSchemaCreationScript(_dialect);
ExecuteScripts(scripts, connection);
}
private static void ExecuteScripts(IEnumerable<string> scripts, IDbConnection connection)
{
foreach (string script in scripts)
{
IDbCommand command = connection.CreateCommand();
command.CommandText = script;
command.ExecuteNonQuery();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment