protected override void SelectFetchEntities(int entityCount) { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); var results = context.Sql("SELECT * FROM Entity WHERE Id <= @0", entityCount).QueryMany<Entity>(); context.Commit(); } }
protected override void ResetDatabase() { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); context.Sql("DELETE FROM Entity").Execute(); context.Sql("DELETE FROM sqlite_sequence WHERE name = @0", "Entity").Execute(); context.Commit(); } }
protected override void DeleteEntities(List<Entity> entities) { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); // Seriously, I have to specify the table every time and call execute via some bizarre api entities.ForEach(entity => context.Delete("Entity", entity).Where(x => x.Id).Execute()); context.Commit(); } }
protected override void InsertEntities(List<Entity> entities) { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); // Ugh, spcifying the table again having to ignore the id and assign the result, this makes me sad :( entities.ForEach(entity => { entity.Id = context.Insert("Entity", entity).AutoMap(x => x.Id).ExecuteReturnLastId<int>(); }); context.Commit(); } }
protected override void UpdateEntities(List<Entity> entities) { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); // And again... entities.ForEach(entity => context.Update("Entity", entity).AutoMap(x => x.Id).Where(x => x.Id).Execute()); context.Commit(); } }
protected override void SelectSingleEntity(int entityCount) { using (var context = new DbContext().ConnectionStringName("SQLiteTest", new SqliteProvider())) { context.UseTransaction(true); do { // So much for a select by ID method! var entity = context.Sql("SELECT * FROM Entity WHERE Id = @0", entityCount).QuerySingle<Entity>(); entityCount--; } while (entityCount > 0); context.Commit(); } }