public ThingRepository(ThingDbContext dbContext) { if (dbContext == null) throw new ArgumentNullException(nameof(dbContext)); Debug.WriteLine($"Create {nameof(ThingRepository)} {dbContext.Identifier}"); _dataSet = dbContext.Things; }
public ThingRepository(ThingDbContext dbContext) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } Debug.WriteLine($"Create {nameof(ThingRepository)} {dbContext.Identifier}"); _dataSet = dbContext.Things; }
internal static void Persist(Action<ThingDbContext> action) { using (var dbContext = new ThingDbContext()) { dbContext.Database.Log = Console.WriteLine; var tx = dbContext.Database.BeginTransaction(); try { action(dbContext); dbContext.SaveChanges(); tx.Commit(); } catch (Exception) { tx.Rollback(); throw; } } }
public UnitOfWork(ThingDbContext dbContext) { Debug.WriteLine($"Create {nameof(UnitOfWork)} {dbContext.Identifier}"); _dbContext = dbContext; }
internal static ThingDbContext CreateDbContext() { var dbContext = new ThingDbContext(); dbContext.Database.Log = Console.WriteLine; return dbContext; }