示例#1
0
        /// <summary>
        /// Rollback of entity changes and return full error message
        /// </summary>
        /// <param name="ex">Exception</param>
        /// <returns>Error</returns>
        protected string GetFullErrorTextAndRollbackEntityChanges(Exception ex)
        {
            var fullErrorText = GetFullErrorText(ex);
            var entities      = _context.ChangeTracker.Entries();

            foreach (var entry in entities)
            {
                if (entry == null)
                {
                    continue;
                }

                //rollback of entity changes
                entry.State = EntityState.Unchanged;
            }

            _context.SaveChanges();
            return(fullErrorText);
        }
示例#2
0
 public void Sil(Tablo tablo)
 {
     using var context = new CoreAppContext();
     context.Set <Tablo>().Remove(tablo);
     context.SaveChanges();
 }
示例#3
0
 public void Guncelle(Tablo tablo)
 {
     using var context = new CoreAppContext();
     context.Set <Tablo>().Update(tablo);
     context.SaveChanges();
 }
示例#4
0
 public void Ekle(Tablo tablo)
 {
     using var context = new CoreAppContext();
     context.Set <Tablo>().Add(tablo);
     context.SaveChanges();
 }
示例#5
0
 public virtual T Create(T entity)
 {
     _dbset.Add(entity);
     dbContext.SaveChanges();
     return(entity);
 }
示例#6
0
 public User Create(User entity)
 {
     dbContext.Users.Add(entity);
     dbContext.SaveChanges();
     return(entity);
 }