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;
        }
Beispiel #3
0
        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;
 }
 public UnitOfWork(ThingDbContext dbContext)
 {
     Debug.WriteLine($"Create {nameof(UnitOfWork)} {dbContext.Identifier}");
     _dbContext = dbContext;
 }
Beispiel #6
0
 internal static ThingDbContext CreateDbContext()
 {
     var dbContext = new ThingDbContext();
     dbContext.Database.Log = Console.WriteLine;
     return dbContext;
 }