예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 public virtual void Update(T entity)
 {
     FillEntity(false, entity);
     // Logger.Debug("Update {0}", entity.ToString());
     DbSet.Attach(entity);
     CurrentDbContext.Entry(entity).State = EntityState.Modified;
 }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 public virtual void Delete(T entity)
 {
     //  Logger.Debug("Delete {0}", entity);
     if (CurrentDbContext.Entry(entity).State == EntityState.Detached)
     {
         DbSet.Attach(entity);
     }
     DbSet.Remove(entity);
 }
예제 #3
0
 public override bool IsNew(T entity)
 {
     return(CurrentDbContext.Entry(entity).State == System.Data.Entity.EntityState.Added);
 }
예제 #4
0
        public void Delete <T>(params object[] keyValues) where T : BaseModel, new()
        {
            var entity = CurrentDbContext.Set <T>().Find(keyValues);

            CurrentDbContext.Entry(entity).State = EntityState.Deleted;
        }
예제 #5
0
 public void Update <T>(T entity) where T : BaseModel, new()
 {
     CurrentDbContext.Entry(entity).State = EntityState.Modified;
 }
예제 #6
0
        public async Task DeleteAsync <T>(params object[] keyValues) where T : BaseModel, new()
        {
            var entity = await CurrentDbContext.Set <T>().FindAsync(keyValues);

            CurrentDbContext.Entry(entity).State = EntityState.Deleted;
        }