public UnitOfWork(IDbFactory dbFactory) { DbFactory = dbFactory; if (DbFactory.Context()?.State == ConnectionState.Closed) { DbFactory.Context().Open(); } DbTransaction = DbFactory.Context().BeginTransaction(); DbClient = new DapperDbClient(DbFactory, DbTransaction); }
public void Dispose() { foreach (var person in personRepository.GetAll()) { personRepository.Remove(person); } dbFactory.Context().SaveChanges(); personRepository.Dispose(); dbFactory.Dispose(); }
public void Dispose() { foreach (var place in repository.GetAll()) { repository.Remove(place); } dbFactory.Context().SaveChanges(); repository.Dispose(); dbFactory.Dispose(); }
public PersonRepositoryTests() { dbFactory = new DbFactory(options); personRepository = new PersonRepository(dbFactory); personRepository.Add(new Person { PersonId = 1, FirstName = "Test", LastName = "Tester", Gender = Gender.Unknown, Status = Status.Unknown }); personRepository.Add(new Person { PersonId = 2, FirstName = "Foo", LastName = "Tester", Gender = Gender.Female, Status = Status.Living }); personRepository.Add(new Person { PersonId = 3, FirstName = "Bar", LastName = "Tester", Gender = Gender.Male, Status = Status.Living }); dbFactory.Context().SaveChanges(); }
public GenericRepositoryTests() { dbFactory = new DbFactory(options); repository = new GenericRepository <Place>(dbFactory); repository.Add(new Place { PlaceId = 1, Name = "Place 1" }); repository.Add(new Place { PlaceId = 2, Name = "Place 2" }); repository.Add(new Place { PlaceId = 3, Name = "Place 3" }); dbFactory.Context().SaveChanges(); }
public UnitOfWork(IDbFactory dbFactory) { Db = dbFactory; Db.Context().Open(); DbTransaction = Db.Context().BeginTransaction(); }