mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-25 04:27:14 +08:00
Enumerations support configuration
This commit is contained in:
@@ -646,9 +646,16 @@ namespace SqlSugar
|
||||
columnInfo.IsArray = true;
|
||||
}
|
||||
if (columnInfo.PropertyType.IsEnum()&& columnInfo.Value!=null)
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
columnInfo.Value = columnInfo.Value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
columnInfo.Value = Convert.ToInt64(columnInfo.Value);
|
||||
}
|
||||
}
|
||||
if (column.IsJson&& columnInfo.Value!=null)
|
||||
{
|
||||
if(columnInfo.Value!=null)
|
||||
|
||||
@@ -195,9 +195,16 @@ namespace SqlSugar
|
||||
return bytesString;
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
|
||||
@@ -303,9 +303,16 @@ namespace SqlSugar
|
||||
return bytesString;
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
|
||||
@@ -571,9 +571,16 @@ namespace SqlSugar
|
||||
TableId = i
|
||||
};
|
||||
if (columnInfo.PropertyType.IsEnum()&& columnInfo.Value!=null)
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
columnInfo.Value = columnInfo.Value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
columnInfo.Value = Convert.ToInt64(columnInfo.Value);
|
||||
}
|
||||
}
|
||||
if (column.IsJson)
|
||||
{
|
||||
columnInfo.IsJson = true;
|
||||
|
||||
@@ -13,5 +13,6 @@ namespace SqlSugar
|
||||
public bool DisableNvarchar { get; set; }
|
||||
public bool PgSqlIsAutoToLower = true;
|
||||
public int DefaultCacheDurationInSeconds { get; set; }
|
||||
public bool? TableEnumIsString { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,16 @@ namespace SqlSugar
|
||||
return bytesString;
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
|
||||
@@ -118,9 +118,16 @@ namespace SqlSugar
|
||||
return bytesString;
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
|
||||
@@ -98,9 +98,16 @@ namespace SqlSugar
|
||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.ByteArrayType)
|
||||
{
|
||||
var parameterName = this.Builder.SqlParameterKeyWord + name + i;
|
||||
|
||||
@@ -60,9 +60,16 @@ namespace SqlSugar
|
||||
return parameterName;
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
}
|
||||
else if (type == UtilConstants.ByteArrayType)
|
||||
{
|
||||
var parameterName = this.Builder.SqlParameterKeyWord + name + i;
|
||||
|
||||
Reference in New Issue
Block a user