数据库是int在实体中直接设置枚举就行了
public DbType DbType{get;set;}数据想要存枚举字符串 那么就需要下面的写法
//新版本:存储字符串 SqlSugar 5.1.4.66-preview02
[SugarColumn(ColumnDataType="varchar(20)",SqlParameterDbType=typeof(EnumToStringConvert))]
public SqlSugar.DbType? EnumValue { get;set; }
//老版:本转字符串
db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings() { TableEnumIsString = true };
db.Queryable<T>().Where(x=> x.type==p ).ToList()//Sql: type= 枚举字符串注意请升级到:SqlSugar 5.1.4.69
Select(it=>new dto()
{
Type=(枚举)(object)it.TypeString
}).ToList()//非匿名对象
var list = db.Queryable<Order>().Select(it=>
new DTO
{
Type= it.Type.ToStrng()//先转成"1" 这种字符串
})
.Mapper(it => {
//这边完全是C#代码可以调试的
it.Type=Enum.GetName(typeof(评价), it.type);
}).ToList();
//匿名对象
Select(it=> (dynamic)new
{
Type=it.Type.ToString()
})
.Mapper(it => {
//这边完全是C#代码可以调试的
it.Type=Enum.GetName(typeof(评价), (string)it.type);
}).ToList();2016 © donet5.comApache Licence 2.0