mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Update TableEnumIsString
This commit is contained in:
parent
3a8aa4f5f2
commit
e9bf020ab0
@ -24,7 +24,14 @@ namespace OrmTest
|
||||
|
||||
db.CodeFirst.InitTables<Unit00Z1string1>();
|
||||
db.Insertable(new Unit00Z1string1() { type = UnitType.a, type2 = null }).ExecuteCommand();
|
||||
var x = db.Queryable<Unit00Z1string1>().Select(it => new
|
||||
List<UnitType> ids = new List<UnitType>() {
|
||||
UnitType.a,
|
||||
UnitType.b
|
||||
};
|
||||
var x = db.Queryable<Unit00Z1string1>()
|
||||
.Where(it => it.type == UnitType.b)
|
||||
.Where(it=>it.type2== UnitType.b)
|
||||
.Where(it=> ids.Contains(it.type)).Select(it => new
|
||||
{
|
||||
x = it.type,
|
||||
x2 = it.type2
|
||||
|
@ -13,6 +13,21 @@ namespace SqlSugar
|
||||
var expression = base.Expression as ConstantExpression;
|
||||
var isLeft = parameter.IsLeft;
|
||||
object value = ExpressionTool.GetValue(expression.Value,this.Context);
|
||||
if (this.Context.TableEnumIsString == true
|
||||
&& value != null
|
||||
&& value.IsInt()
|
||||
&& base.BaseParameter?.OppsiteExpression != null)
|
||||
{
|
||||
if (base.BaseParameter?.OppsiteExpression is UnaryExpression)
|
||||
{
|
||||
var oppsiteExpression = base.BaseParameter?.OppsiteExpression as UnaryExpression;
|
||||
var oppsiteValue = oppsiteExpression.Operand;
|
||||
if (oppsiteValue.Type.IsEnum())
|
||||
{
|
||||
value = UtilMethods.ChangeType2(value, oppsiteValue.Type).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
var baseParameter = parameter.BaseParameter;
|
||||
baseParameter.ChildExpression = expression;
|
||||
var isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);
|
||||
|
@ -678,6 +678,24 @@ namespace SqlSugar
|
||||
model.Args[0].MemberValue = first.Value;
|
||||
}
|
||||
}
|
||||
if (this.Context.TableEnumIsString == true)
|
||||
{
|
||||
List<string> enumStringList = new List<string>();
|
||||
foreach (var inItem in (model.Args[0].MemberValue as IEnumerable))
|
||||
{
|
||||
if (inItem != null)
|
||||
{
|
||||
if (UtilMethods.GetUnderType(inItem.GetType()).IsEnum())
|
||||
{
|
||||
enumStringList.Add(inItem.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enumStringList.Any())
|
||||
{
|
||||
model.Args[0].MemberValue = enumStringList;
|
||||
}
|
||||
}
|
||||
var caResult = this.Context.DbMehtods.ContainsArray(model);
|
||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||
return caResult;
|
||||
|
Loading…
Reference in New Issue
Block a user