Example #1
0
        public RepositoryDocentiTest()
        {
            var options = new DbContextOptionsBuilder <ContestoFinsa>()
                          .UseInMemoryDatabase("InMemory" + counter++)
                          .Options;

            ctx = new ContestoFinsa(options);
            docentiRepository = new RepositoryDocenti(ctx);
            ctx.Docenti.AddRange(CreaDocenti(10));
            ctx.SaveChanges();
        }
Example #2
0
 public void Save()
 {
     try
     {
         ctx.SaveChanges();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new ConnectionException(e.Message);
     }
     catch (DbUpdateException e)
     {
         throw new DBEditException(e.Message);
     }
 }