Synchronization code

This commit is contained in:
sunkaixuan 2023-02-12 15:02:04 +08:00
parent 6c4a7cf073
commit 9392aae738
4 changed files with 39 additions and 1 deletions

View File

@ -689,12 +689,42 @@ namespace SqlSugar
{ {
throw new NotImplementedException("Current database no support"); throw new NotImplementedException("Current database no support");
} }
public string CompareTo(MethodCallExpressionModel model) public virtual string CompareTo(MethodCallExpressionModel model)
{ {
var parameterNameA=model.Args[0].MemberName; var parameterNameA=model.Args[0].MemberName;
var parameterNameB = model.Args[1].MemberName; var parameterNameB = model.Args[1].MemberName;
return $"(case when {parameterNameA}>{parameterNameB} then 1 when {parameterNameA}={parameterNameB} then 0 else -1 end)"; return $"(case when {parameterNameA}>{parameterNameB} then 1 when {parameterNameA}={parameterNameB} then 0 else -1 end)";
} }
public virtual string SplitIn(MethodCallExpressionModel model)
{
var fullString = model.Args[0].MemberName+"";
var value = model.Args[1].MemberName+"";
var value1 = MergeString(value, "','");
var value2 = MergeString("','", value);
var value3 = MergeString("','", value, "','");
var likeString1 =
StartsWith(new MethodCallExpressionModel() { Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ IsMember=true, MemberName=fullString },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=value1 }
} });
var likeString2 =
EndsWith(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ IsMember=true, MemberName=fullString },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=value2 }
}
});
var likeString3 =
Contains(new MethodCallExpressionModel()
{
Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ IsMember=true, MemberName=fullString },
new MethodCallExpressionArgs(){ IsMember=true, MemberName=value3 }
}
});
return $" ({likeString1} or {likeString2} or {likeString3} or {fullString}={value} ) ";
}
public virtual string GetTableWithDataBase(string dataBaseName,string tableName) public virtual string GetTableWithDataBase(string dataBaseName,string tableName)
{ {
return $"{dataBaseName}.{tableName}"; return $"{dataBaseName}.{tableName}";

View File

@ -103,6 +103,7 @@ namespace SqlSugar
string JsonListObjectAny(MethodCallExpressionModel model); string JsonListObjectAny(MethodCallExpressionModel model);
string JsonArrayAny(MethodCallExpressionModel model); string JsonArrayAny(MethodCallExpressionModel model);
string CompareTo(MethodCallExpressionModel model); string CompareTo(MethodCallExpressionModel model);
string SplitIn(MethodCallExpressionModel model);
string GetTableWithDataBase(string databaseName,string tableName); string GetTableWithDataBase(string databaseName,string tableName);
} }
} }

View File

@ -278,5 +278,10 @@ namespace SqlSugar
{ {
throw new NotSupportedException("Can only be used in expressions"); throw new NotSupportedException("Can only be used in expressions");
} }
public static bool SplitIn(string CommaSegmentationString, string inValue)
{
throw new NotSupportedException("Can only be used in expressions");
}
} }
} }

View File

@ -783,6 +783,8 @@ namespace SqlSugar
return this.Context.DbMehtods.JsonArrayAny(model); return this.Context.DbMehtods.JsonArrayAny(model);
case "CompareTo": case "CompareTo":
return this.Context.DbMehtods.CompareTo(model); return this.Context.DbMehtods.CompareTo(model);
case "SplitIn":
return this.Context.DbMehtods.SplitIn(model);
default: default:
break; break;
} }