mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Enum type optimization
This commit is contained in:
parent
10d5537a08
commit
f8573c65b9
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user