示例#1
0
        private int EditData(IConnectinContext cc, ObjectMapper om)
        {
            if (om.ID == null)
            {
                throw new PeanutException(DataMsg.UPDATE_ERROR_ID_NOTFOUND);
            }
            Update update = new Update(om.Table);

            for (int i = 0; i < om.Properties.Count; i++)
            {
                PropertyMapper pm = om.Properties[i];

                System.Reflection.PropertyInfo pi = pm.Handler.Property;
                if (EntityState._FieldState.ContainsKey(pm.Handler.Property.Name))
                {
                    if (pm.Cast != null)
                    {
                        update.AddField(pm.ColumnName, "p_" + pi.Name, pm.Cast.ToColumn(pm.Handler.Get(this),
                                                                                        pm.Handler.Property.PropertyType, this));
                    }
                    else
                    {
                        update.AddField(pm.ColumnName, "p_" + pi.Name, pm.Handler.Get(this));
                    }
                }
            }
            update.Where.SqlText.Append(om.ID.ColumnName).Append("=@p1");
            update.Where.Parameters.Add(new Command.Parameter {
                Name = "p1", Value = om.ID.Handler.Get(this)
            });
            return(update.Execute(cc));
        }
示例#2
0
 private int EditData(IConnectinContext cc,ObjectMapper om)
 {
     if (om.ID == null)
         throw new PeanutException(DataMsg.UPDATE_ERROR_ID_NOTFOUND);
     Update update = new Update(om.Table);
     for (int i = 0; i < om.Properties.Count; i++)
     {
         PropertyMapper pm= om.Properties[i];
     
         System.Reflection.PropertyInfo pi = pm.Handler.Property;
         if (EntityState._FieldState.ContainsKey(pm.Handler.Property.Name))
         {
             if (pm.Cast != null)
             {
                 update.AddField(pm.ColumnName,"p_"+pi.Name,pm.Cast.ToColumn(pm.Handler.Get(this),
                     pm.Handler.Property.PropertyType,this));
             }
             else
             {
                 update.AddField(pm.ColumnName, "p_" + pi.Name, pm.Handler.Get(this));
             }
         }
     }
     update.Where.SqlText.Append(om.ID.ColumnName).Append("=@p1");
     update.Where.Parameters.Add(new Command.Parameter { Name = "p1", Value = om.ID.Handler.Get(this) });
     return update.Execute(cc);
     
 }