示例#1
0
 public async Task InsertAsync(Customer entity)
 {
     using (var ctx = new ImaginCrudContext())
     {
         if (await ctx.Customers.AnyAsync(x => x.CustomerId.Equals(entity.CustomerId)))
         {
             throw new DuplicatedEntityException($"Ya existe un cliente con número de documento {entity.CustomerId}.");
         }
     }
 }
示例#2
0
 public void Insert(List <Customer> entity)
 {
     using (var ctx = new ImaginCrudContext())
     {
         foreach (var item in entity)
         {
             if (ctx.Customers.Any(x => x.CustomerId.Equals(item.CustomerId)))
             {
                 throw new DuplicatedEntityException($"Ya existe un cliente con número de documento {item.CustomerId}.");
             }
         }
     }
 }
示例#3
0
文件: Startup.cs 项目: ludaher/typing
 private void _MigrateDataBase()
 {
     Logger.Info("Iniciando migración");
     try
     {
         using (var db = new ImaginCrudContext())
         {
             db.Database.Migrate();
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Error ejecutando la migración de la base de datos", ex);
     }
 }