mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Enum type optimization
This commit is contained in:
@@ -248,6 +248,17 @@ namespace SqlSugar
|
||||
public static T GetEnum<T>(this IDataReader dr, int i) where T : struct
|
||||
{
|
||||
object value = dr.GetValue(i);
|
||||
if (value != null)
|
||||
{
|
||||
if (value.GetType() == UtilConstants.DecType)
|
||||
{
|
||||
value = Convert.ToUInt32(value);
|
||||
}
|
||||
else if (value.GetType() == UtilConstants.StringType)
|
||||
{
|
||||
return (T)Enum.Parse(typeof(T), value.ObjToString());
|
||||
}
|
||||
}
|
||||
T t = (T)Enum.ToObject(typeof(T), value);
|
||||
return t;
|
||||
}
|
||||
|
Reference in New Issue
Block a user