public void Create_Sqlite_Database() { var dbPath = "~/App_Data/db.sqlite".MapAbsolutePath(); var dbFactory = new OrmLiteConnectionFactory( dbPath, SqliteOrmLiteDialectProvider.Instance); if (File.Exists(dbPath)) { File.Delete(dbPath); } NorthwindData.LoadData(); dbFactory.Exec(dbCmd => { dbCmd.CreateTables(false, NorthwindFactory.ModelTypes.ToArray()); dbCmd.SaveAll(NorthwindData.Categories); dbCmd.SaveAll(NorthwindData.Customers); dbCmd.SaveAll(NorthwindData.CustomerCustomerDemos); dbCmd.SaveAll(NorthwindData.Employees); dbCmd.SaveAll(NorthwindData.EmployeeTerritories); dbCmd.SaveAll(NorthwindData.OrderDetails); dbCmd.SaveAll(NorthwindData.Orders); dbCmd.SaveAll(NorthwindData.Products); dbCmd.SaveAll(NorthwindData.Products); dbCmd.SaveAll(NorthwindData.Regions); dbCmd.SaveAll(NorthwindData.Shippers); dbCmd.SaveAll(NorthwindData.Suppliers); dbCmd.SaveAll(NorthwindData.Territories); }); }
public void SetUp() { //Setup SQL Server Connection Factory dbFactory = new OrmLiteConnectionFactory( ConfigurationManager.ConnectionStrings["testDb"].ConnectionString, MySqlDialectProvider.Instance); dbFactory.Exec(dbCmd => dbCmd.CreateTable<User>(overwrite: true)); }
public void SetUp() { //Setup SQL Server Connection Factory dbFactory = new OrmLiteConnectionFactory( ConfigurationManager.ConnectionStrings["testDb"].ConnectionString, MySqlDialectProvider.Instance); dbFactory.Exec(dbCmd => dbCmd.CreateTable <User>(overwrite: true)); }
public void SetUp() { //Setup SQL Server Connection Factory dbFactory = new OrmLiteConnectionFactory( @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\Database1.mdf;Integrated Security=True;User Instance=True", SqlServerOrmLiteDialectProvider.Instance); dbFactory.Exec(dbCmd => dbCmd.CreateTable <User>(overwrite: true)); }
public void SetUp() { //Setup SQL Server Connection Factory dbFactory = new OrmLiteConnectionFactory( @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\Database1.mdf;Integrated Security=True;User Instance=True", SqlServerOrmLiteDialectProvider.Instance); dbFactory.Exec(dbCmd => dbCmd.CreateTable<User>(overwrite: true)); }
public void SetUp() { try { tests = new OAuthUserSessionTests(); var inMemoryRepo = new InMemoryAuthRepository(); inMemoryRepo.Clear(); userAuthRepositorys.Add(inMemoryRepo); var redisRepo = new RedisAuthRepository(new BasicRedisClientManager()); redisRepo.Clear(); userAuthRepositorys.Add(redisRepo); if (OAuthUserSessionTestsBase.UseSqlServer) { var connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\auth.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; var sqlServerFactory = new OrmLiteConnectionFactory(connStr, SqlServerOrmLiteDialectProvider.Instance); var sqlServerRepo = new OrmLiteAuthRepository(sqlServerFactory); sqlServerRepo.DropAndReCreateTables(); } else { var sqliteInMemoryRepo = new OrmLiteAuthRepository(dbFactory); dbFactory.Exec(dbCmd => { dbCmd.CreateTable <UserAuth>(true); dbCmd.CreateTable <UserOAuthProvider>(true); }); sqliteInMemoryRepo.Clear(); userAuthRepositorys.Add(sqliteInMemoryRepo); var sqliteDbFactory = new OrmLiteConnectionFactory( "~/App_Data/auth.sqlite".MapProjectPath()); var sqliteDbRepo = new OrmLiteAuthRepository(sqliteDbFactory); sqliteDbRepo.CreateMissingTables(); userAuthRepositorys.Add(sqliteDbRepo); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }