mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-25 04:27:14 +08:00
Optimize table query
This commit is contained in:
@@ -504,8 +504,8 @@ namespace OrmTest
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Like, FieldValue = "1" });// id like '%1%'
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.IsNullOrEmpty });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.In, FieldValue = "1,2,3" });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.NotIn, FieldValue = "1,2,3" });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.In, FieldValue = "1,2,3",CSharpTypeName="int" });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.NotIn, FieldValue = "1,2,3" ,CSharpTypeName="int" });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.NoEqual, FieldValue = "1,2,3" });
|
||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.IsNot, FieldValue = null });// id is not null
|
||||
|
||||
|
||||
@@ -189,12 +189,20 @@ namespace SqlSugar
|
||||
case ConditionalType.In:
|
||||
if (item.FieldValue == null) item.FieldValue = string.Empty;
|
||||
var inValue1 = ("(" + item.FieldValue.Split(',').ToJoinSqlInVals() + ")");
|
||||
if (item.CSharpTypeName.HasValue()&&UtilMethods.IsNumber(item.CSharpTypeName))
|
||||
{
|
||||
inValue1= inValue1.Replace("'","");
|
||||
}
|
||||
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "IN", inValue1);
|
||||
parameters.Add(new SugarParameter(parameterName, item.FieldValue));
|
||||
break;
|
||||
case ConditionalType.NotIn:
|
||||
if (item.FieldValue == null) item.FieldValue = string.Empty;
|
||||
var inValue2 = ("(" + item.FieldValue.Split(',').ToJoinSqlInVals() + ")");
|
||||
if (item.CSharpTypeName.HasValue() && UtilMethods.IsNumber(item.CSharpTypeName))
|
||||
{
|
||||
inValue2 = inValue2.Replace("'", "");
|
||||
}
|
||||
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "NOT IN", inValue2);
|
||||
parameters.Add(new SugarParameter(parameterName, item.FieldValue));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user