|
|
|
@ -23,13 +23,16 @@ namespace Rs.Framework
|
|
|
|
|
PropertyInfo[] pis = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
|
|
|
|
foreach (PropertyInfo propertyInfo in pis)
|
|
|
|
|
{
|
|
|
|
|
if(propertyInfo.PropertyType.IsEnum)
|
|
|
|
|
if(dr.Table.Columns.Contains(propertyInfo.Name))
|
|
|
|
|
{
|
|
|
|
|
propertyInfo.SetValue(entity, Enum.Parse(propertyInfo.PropertyType, dr[propertyInfo.Name].ToString()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
propertyInfo.SetValue(entity, Convert.ChangeType(dr[propertyInfo.Name], propertyInfo.PropertyType));
|
|
|
|
|
if (propertyInfo.PropertyType.IsEnum)
|
|
|
|
|
{
|
|
|
|
|
propertyInfo.SetValue(entity, Enum.Parse(propertyInfo.PropertyType, dr[propertyInfo.Name].ToString()));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
propertyInfo.SetValue(entity, Convert.ChangeType(dr[propertyInfo.Name], propertyInfo.PropertyType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return entity;
|
|
|
|
|