feat: 增加枚举类型入库时 ToString
This commit is contained in:
parent
fa6c0e302f
commit
4a3582748b
|
@ -64,13 +64,12 @@ namespace BootstrapAdmin.DataAccess.PetaPoco
|
|||
return ci;
|
||||
}
|
||||
|
||||
public override Func<object?, object?> GetFromDbConverter(PropertyInfo targetProperty, Type sourceType)
|
||||
{
|
||||
if (targetProperty.PropertyType.IsEnum && sourceType == typeof(string))
|
||||
{
|
||||
return new StringToEnumConverter(targetProperty.PropertyType).ConvertFromDb;
|
||||
}
|
||||
return base.GetFromDbConverter(targetProperty, sourceType);
|
||||
}
|
||||
public override Func<object?, object?> GetFromDbConverter(PropertyInfo targetProperty, Type sourceType) => targetProperty.PropertyType.IsEnum && sourceType == typeof(string)
|
||||
? new StringToEnumConverter(targetProperty.PropertyType).ConvertFromDb
|
||||
: base.GetFromDbConverter(targetProperty, sourceType);
|
||||
|
||||
public override Func<object?, object?> GetToDbConverter(PropertyInfo targetProperty) => targetProperty.PropertyType.IsEnum
|
||||
? new StringToEnumConverter(targetProperty.PropertyType).ConvertToDb
|
||||
: base.GetToDbConverter(targetProperty);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue