Created
March 12, 2009 01:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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