mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
Add CommonPropertyConvert
This commit is contained in:
@@ -32,4 +32,22 @@ namespace SqlSugar.DbConvert
|
||||
return (T)Enum.Parse(undertype, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CommonPropertyConvert : ISugarDataConverter
|
||||
{
|
||||
public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
|
||||
{
|
||||
var name = "@MyEnmu" + columnIndex;
|
||||
Type undertype = SqlSugar.UtilMethods.GetUnderType(typeof(T));//获取没有nullable的枚举类型
|
||||
return new SugarParameter(name, columnValue, undertype);
|
||||
}
|
||||
|
||||
public T QueryConverter<T>(IDataRecord dr, int i)
|
||||
{
|
||||
|
||||
var value = dr.GetValue(i);
|
||||
return (T)UtilMethods.ChangeType2(value, typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user