예제 #1
0
파일: Reflex.cs 프로젝트: fjiang2/sqlcon
        public static object FillField(object instance, PropertyInfo propertyInfo, DataRow dataRow, bool defaultValueUsed)
        {
            ColumnAttribute a = Reflex.GetColumnAttribute(dataRow, propertyInfo);

            if (a != null)
            {
                object value = dataRow[a.ColumnName];

                if (value == System.DBNull.Value)
                {
                    if (a.DefaultValue != null)
                    {
                        value = a.DefaultValue;
                    }
                    else if (defaultValueUsed)
                    {
                        Type dataType = dataRow.Table.Columns[a.ColumnName].DataType;
                        value = DefaultRowValue.SystemDefaultValue(dataType);
                    }
                    else
                    {
                        value = null;
                    }
                }

                propertyInfo.SetValue(instance, value, null);
            }

            return(a);
        }
예제 #2
0
        public virtual void Clear()
        {
            foreach (PropertyInfo propertyInfo in this.columnProperties)
            {
                object value = null;

                if (propertyInfo.PropertyType.IsValueType)
                {
                    value = DefaultRowValue.SystemDefaultValue(propertyInfo.PropertyType);
                }

                propertyInfo.SetValue(this, value, null);
            }
        }