public void Remove(IEnumerable <T> items)
 {
     try
     {
         _dbSet.RemoveRange(items);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
     }
 }
 public IEnumerable <T> Get(Func <T, bool> predicate)
 {
     try
     {
         return(_dbSet.Where(predicate).ToList());
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
         return(null);
     }
 }
 public void Remove(int id)
 {
     try
     {
         _dbSet.Remove(_dbSet.Find(id));
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
     }
 }
 public virtual IEnumerable <T> GetAll()
 {
     try
     {
         return(_dbSet.AsNoTracking().ToList());
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
         return(null);
     }
 }
 public virtual T FindById(int id)
 {
     try
     {
         return(_dbSet.Find(id));
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
         return(null);
     }
 }
 public virtual void Add(IEnumerable <T> items)
 {
     try
     {
         _dbSet.AddRange(items);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
     }
 }
 public virtual void Add(T item)
 {
     try
     {
         _dbSet.Add(item);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
     }
 }
 public virtual void Update(T item)
 {
     try
     {
         _context.Entry(item).State = EntityState.Modified;
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
     }
 }
示例#9
0
 public override IEnumerable <T> GetAll()
 {
     try
     {
         IEnumerable <T> item = (IEnumerable <T>)_context.BookAuthors.Include(e => e.Book).Include(p => p.Author).ToList();
         return(item);
     }
     catch (Exception ex)
     {
         LogRegistrator.Write(ex);
         return(null);
     }
 }