public int Update(TEntity entity) { lock (OBJLOCK) { VerifyExtension.Verity(entity); RemoveHoldingEntityInContext(entity); dbcontext.Set <TEntity>().Attach(entity); PropertyInfo[] props = entity.GetType().GetProperties(); foreach (PropertyInfo prop in props) { Object[] attrs = prop.GetCustomAttributes(true); string strDesc = string.Empty; NotMappedAttribute notMapped = Attribute.GetCustomAttribute(prop, typeof(NotMappedAttribute)) as NotMappedAttribute; if (notMapped == null) { if (prop.GetValue(entity, null) != null) { if (prop.GetValue(entity, null).ToString() == " ") { dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null; } dbcontext.Entry(entity).Property(prop.Name).IsModified = true; } } } return(dbcontext.SaveChanges()); } }
public int Insert <TEntity>(List <TEntity> entitys) where TEntity : class { foreach (var entity in entitys) { VerifyExtension.Verity(entity); dbcontext.Entry <TEntity>(entity).State = EntityState.Added; } return(dbTransaction == null?this.Commit() : 0); }
public int Insert(TEntity entity) { lock (OBJLOCK) { VerifyExtension.Verity(entity); RemoveHoldingEntityInContext(entity); dbcontext.Entry <TEntity>(entity).State = EntityState.Added; return(dbcontext.SaveChanges()); } }
public int Insert(List <TEntity> entitys) { lock (OBJLOCK) { foreach (var entity in entitys) { VerifyExtension.Verity(entity); RemoveHoldingEntityInContext(entity); dbcontext.Entry <TEntity>(entity).State = EntityState.Added; } return(dbcontext.SaveChanges()); } }
public int Update <TEntity>(TEntity entity) where TEntity : class { VerifyExtension.Verity(entity); dbcontext.Set <TEntity>().Attach(entity); PropertyInfo[] props = entity.GetType().GetProperties(); foreach (PropertyInfo prop in props) { NotMappedAttribute notMapped = Attribute.GetCustomAttribute(prop, typeof(NotMappedAttribute)) as NotMappedAttribute; if (notMapped == null) { if (prop.GetValue(entity, null) != null) { if (prop.GetValue(entity, null).ToString() == " ") { dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null; } dbcontext.Entry(entity).Property(prop.Name).IsModified = true; } } } return(dbTransaction == null?this.Commit() : 0); }
public int Insert <TEntity>(TEntity entity) where TEntity : class { VerifyExtension.Verity(entity); dbcontext.Entry <TEntity>(entity).State = EntityState.Added; return(dbTransaction == null?this.Commit() : 0); }