public override void MapToEntity(object obj)
{
DBSettleAccountWithWaitingSummary summary =( DBSettleAccountWithWaitingSummary)obj;
Type entityType = this.GetType();
PropertyInfo[] ePropertyInfos = entityType.GetProperties();
string propertyName;
foreach (PropertyInfo ePropertyInfo in ePropertyInfos)
{
propertyName=ePropertyInfo.Name;
if (propertyName.Equals("GetAction") || propertyName.Equals("DisplayText")) continue;
PropertyInfo dbPropertyInfo = summary.GetType().GetProperty(propertyName);
ePropertyInfo.SetValue(this, dbPropertyInfo.GetValue(summary, null).ChangeType(ePropertyInfo.PropertyType), null);
}
}
{
DBSettleAccountWithWaitingSummary summary =( DBSettleAccountWithWaitingSummary)obj;
Type entityType = this.GetType();
PropertyInfo[] ePropertyInfos = entityType.GetProperties();
string propertyName;
foreach (PropertyInfo ePropertyInfo in ePropertyInfos)
{
propertyName=ePropertyInfo.Name;
if (propertyName.Equals("GetAction") || propertyName.Equals("DisplayText")) continue;
PropertyInfo dbPropertyInfo = summary.GetType().GetProperty(propertyName);
ePropertyInfo.SetValue(this, dbPropertyInfo.GetValue(summary, null).ChangeType(ePropertyInfo.PropertyType), null);
}
}
public static class ZBConvert
{
public static object ChangeType(this object value, Type conversionType)
{
if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value != null)
{
NullableConverter nullableConverter = new NullableConverter(conversionType);
conversionType = nullableConverter.UnderlyingType;
}
else
{
return null;
}
}
return Convert.ChangeType(value, conversionType);
}
}
{
public static object ChangeType(this object value, Type conversionType)
{
if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value != null)
{
NullableConverter nullableConverter = new NullableConverter(conversionType);
conversionType = nullableConverter.UnderlyingType;
}
else
{
return null;
}
}
return Convert.ChangeType(value, conversionType);
}
}