mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Add user case test
This commit is contained in:
@@ -50,6 +50,44 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
throw new Exception("unit error");
|
throw new Exception("unit error");
|
||||||
}
|
}
|
||||||
|
var datas=db.Queryable<Uinitadfa22122X>()
|
||||||
|
.Where(it => it.EnumValue.Contains("a"))
|
||||||
|
.ToSql();
|
||||||
|
if (datas.Value.FirstOrDefault().DbType != System.Data.DbType.AnsiString)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Uinitadfa22122X
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType = "varchar(20)", SqlParameterDbType = typeof(Uinitadfa22122XConvert), IsNullable = true)]
|
||||||
|
public string EnumValue { get; set; }
|
||||||
|
}
|
||||||
|
public class Uinitadfa22122XConvert : ISugarDataConverter
|
||||||
|
{
|
||||||
|
public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
|
||||||
|
{
|
||||||
|
var name = "@MyEnmu" + columnIndex;
|
||||||
|
Type undertype = SqlSugar.UtilMethods.GetUnderType(typeof(T));//获取没有nullable的枚举类型
|
||||||
|
if (columnValue == null)
|
||||||
|
{
|
||||||
|
return new SugarParameter(name, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SugarParameter(name, columnValue) { DbType=System.Data.DbType.AnsiString };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T QueryConverter<T>(IDataRecord dr, int i)
|
||||||
|
{
|
||||||
|
|
||||||
|
var str = dr.GetString(i);
|
||||||
|
Type undertype = SqlSugar.UtilMethods.GetUnderType(typeof(T));//获取没有nullable的枚举类型
|
||||||
|
return (T)Enum.Parse(undertype, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Uinitadfa22122
|
public class Uinitadfa22122
|
||||||
|
Reference in New Issue
Block a user