public async Task <List <TEntity> > GetAll()
 {
     using (var db = new MsSqlDbContext())
     {
         return(await db.Set <TEntity>().ToListAsync());
     }
 }
 public void Update(TEntity entity)
 {
     using (var db = new MsSqlDbContext())
     {
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void Insert(TEntity entity)
 {
     using (var db = new MsSqlDbContext())
     {
         db.Set <TEntity>().Add(entity);
         db.SaveChanges();
     }
 }
 public TEntity GetById(int id)
 {
     using (var db = new MsSqlDbContext())
     {
         var result = db.Set <TEntity>().Find(id);
         return(result);
     }
 }
 public void Delete(TEntity entity)
 {
     using (var db = new MsSqlDbContext())
     {
         db.Set <TEntity>().Remove(entity);
         db.SaveChanges();
     }
 }