Example #1
0
        private static void OnClone(object source, object newobj, Mappings.ObjectMapper om)
        {
            object value = null;

            Mappings.PropertyMapper pm = om.ID;
            if (pm != null)
            {
                value = pm.Handler.Get(source);
                if (value != null)
                {
                    pm.Handler.Set(newobj, value);
                }
            }
            for (int i = 0; i < om.Properties.Count; i++)
            {
                Mappings.PropertyMapper p = om.Properties[i];
                value = p.Handler.Get(source);
                if (value != null)
                {
                    p.Handler.Set(newobj, value);
                }
            }
        }
Example #2
0
 private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty rp, PropertyMapper pm, PropertyHandler handler)
 {
     try
     {
         object dbvalue = reader[rp.Index];
         if (dbvalue != DBNull.Value)
         {
             if (pm.Cast != null)
             {
                 dbvalue = pm.Cast.ToProperty(dbvalue, pm.Handler.Property.PropertyType, obj);
             }
             handler.Set(obj, Convert.ChangeType(dbvalue, pm.Handler.Property.PropertyType));
         }
     }
     catch (Exception e_)
     {
         throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, pm.ColumnName, pm.Handler.Property.Name), e_);
     }
 }