コード例 #1
0
 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() == "&nbsp;")
                     {
                         dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null;
                     }
                     dbcontext.Entry(entity).Property(prop.Name).IsModified = true;
                 }
             }
         }
         return(dbcontext.SaveChanges());
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public int Insert(TEntity entity)
 {
     lock (OBJLOCK)
     {
         VerifyExtension.Verity(entity);
         RemoveHoldingEntityInContext(entity);
         dbcontext.Entry <TEntity>(entity).State = EntityState.Added;
         return(dbcontext.SaveChanges());
     }
 }
コード例 #4
0
 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());
     }
 }
コード例 #5
0
 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() == "&nbsp;")
                 {
                     dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null;
                 }
                 dbcontext.Entry(entity).Property(prop.Name).IsModified = true;
             }
         }
     }
     return(dbTransaction == null?this.Commit() : 0);
 }
コード例 #6
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);
 }