mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
Synchronization code
This commit is contained in:
@@ -900,6 +900,85 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public string ListAll(MethodCallExpressionModel model)
|
||||
{
|
||||
if (IsArrayAnyParameter(model))
|
||||
{
|
||||
return ListArrayAny(model);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (model.Args[0].MemberValue != null && (model.Args[0].MemberValue as IList).Count > 0)
|
||||
{
|
||||
sb.Append(" ( ");
|
||||
var listPar = model.Args[1].MemberValue as ListAnyParameter;
|
||||
foreach (var item in (model.Args[0].MemberValue as IList))
|
||||
{
|
||||
var sql = listPar.Sql;
|
||||
if (sb.Length > 3)
|
||||
{
|
||||
sb.Append("AND");
|
||||
}
|
||||
foreach (var columnInfo in listPar.Columns)
|
||||
{
|
||||
var replace = listPar.ConvetColumnFunc($"{listPar.Name}.{columnInfo.DbColumnName}");
|
||||
if (sql.Contains(replace))
|
||||
{
|
||||
var value = columnInfo.PropertyInfo.GetValue(item);
|
||||
var newValue = "null";
|
||||
if (value != null)
|
||||
{
|
||||
if (UtilMethods.IsNumber(columnInfo.UnderType.Name))
|
||||
{
|
||||
newValue = value.ToString();
|
||||
}
|
||||
else if (columnInfo.UnderType == SqlSugar.UtilConstants.GuidType)
|
||||
{
|
||||
newValue = ToGuid(new MethodCallExpressionModel()
|
||||
{
|
||||
Args = new List<MethodCallExpressionArgs>()
|
||||
{
|
||||
new MethodCallExpressionArgs(){
|
||||
MemberValue=value.ToSqlValue(),
|
||||
MemberName=value.ToSqlValue()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (columnInfo.UnderType == SqlSugar.UtilConstants.DateType)
|
||||
{
|
||||
newValue = ToDate(new MethodCallExpressionModel()
|
||||
{
|
||||
Args = new List<MethodCallExpressionArgs>()
|
||||
{
|
||||
new MethodCallExpressionArgs(){
|
||||
MemberValue=UtilMethods.GetConvertValue( value).ToSqlValue(),
|
||||
MemberName=UtilMethods.GetConvertValue( value).ToSqlValue()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue = value.ToSqlValue();
|
||||
}
|
||||
}
|
||||
sql = sql.Replace(replace, newValue);
|
||||
}
|
||||
}
|
||||
sb.Append(sql);
|
||||
}
|
||||
sb.Append(" ) ");
|
||||
}
|
||||
var result = sb.ToString();
|
||||
if (result.IsNullOrEmpty())
|
||||
{
|
||||
return " 1=2 ";
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public virtual string GetTableWithDataBase(string dataBaseName,string tableName)
|
||||
{
|
||||
return $"{dataBaseName}.{tableName}";
|
||||
|
@@ -111,6 +111,7 @@ namespace SqlSugar
|
||||
string CompareTo(MethodCallExpressionModel model);
|
||||
string SplitIn(MethodCallExpressionModel model);
|
||||
string ListAny(MethodCallExpressionModel model);
|
||||
string ListAll(MethodCallExpressionModel model);
|
||||
string GetTableWithDataBase(string databaseName,string tableName);
|
||||
string Modulo(MethodCallExpressionModel mode);
|
||||
string Like(MethodCallExpressionModel mode);
|
||||
|
@@ -385,5 +385,9 @@ namespace SqlSugar
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
public static bool ListAll<T>(List<T> listConstant, Expression<Func<T, bool>> expression)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -103,6 +103,10 @@ namespace SqlSugar
|
||||
{
|
||||
parameter.CommonTempData = GetNewExpressionValue(item);
|
||||
}
|
||||
else if (ExpressionTool.GetMethodName(item) == "All" && !ExpressionTool.GetTopLevelMethodCalls(item).Contains("Subqueryable"))
|
||||
{
|
||||
parameter.CommonTempData = GetNewExpressionValue(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Start();
|
||||
|
@@ -168,6 +168,10 @@ namespace SqlSugar
|
||||
{
|
||||
name = "ListAny";
|
||||
}
|
||||
else if (name == "All" && ExpressionTool.IsVariable(express.Arguments[0]))
|
||||
{
|
||||
name = "ListAll";
|
||||
}
|
||||
var args = express.Arguments.Cast<Expression>().ToList();
|
||||
MethodCallExpressionModel model = new MethodCallExpressionModel();
|
||||
model.Args = new List<MethodCallExpressionArgs>();
|
||||
|
@@ -266,7 +266,7 @@ namespace SqlSugar
|
||||
}
|
||||
model.Args.Add(argItem);
|
||||
}
|
||||
else if (name == "ListAny" && item is LambdaExpression)
|
||||
else if (name.IsIn("ListAny","ListAll") && item is LambdaExpression)
|
||||
{
|
||||
var sql = GetNewExpressionValue(item, ResolveExpressType.WhereMultiple);
|
||||
var lamExp = (item as LambdaExpression);
|
||||
@@ -911,6 +911,10 @@ namespace SqlSugar
|
||||
this.Context.Result.IsNavicate = true;
|
||||
this.Context.Parameters.RemoveAll(it => model.Args[0].MemberName.ObjToString().Contains(it.ParameterName));
|
||||
return this.Context.DbMehtods.ListAny(model);
|
||||
case "ListAll":
|
||||
this.Context.Result.IsNavicate = true;
|
||||
this.Context.Parameters.RemoveAll(it => model.Args[0].MemberName.ObjToString().Contains(it.ParameterName));
|
||||
return this.Context.DbMehtods.ListAll(model);
|
||||
case "Modulo":
|
||||
return this.Context.DbMehtods.Modulo(model);
|
||||
case "Like":
|
||||
@@ -967,6 +971,10 @@ namespace SqlSugar
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (expression.Method.Name == "All" && expression.Arguments.Count() > 0 && ExpressionTool.IsVariable(expression.Arguments[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (expression.Method.Name == "Format" && expression.Method.DeclaringType == UtilConstants.StringType)
|
||||
{
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user