Synchronization code

This commit is contained in:
sunkaixuan
2022-07-30 18:48:09 +08:00
parent cbc5e18636
commit ce39c21098
2 changed files with 23 additions and 7 deletions

View File

@@ -514,12 +514,24 @@ namespace SqlSugar
var method = item as MethodCallExpression;
var queryable = this.Context.Queryable<object>();
if (method.Method.Name == "Where")
{
if (method.Arguments[1].Type == typeof(List<IConditionalModel>))
{
//var x=method.Arguments[1];
var conditionals = ExpressionTool.GetExpressionValue(method.Arguments[1]) as List<IConditionalModel>;
var whereObj = queryable.QueryBuilder.Builder.ConditionalModelToSql(conditionals);
where.Add(whereObj.Key);
if(whereObj.Value!=null)
result.Parameters.AddRange(whereObj.Value);
}
else
{
CheckHasRootShortName(method.Arguments[0], method.Arguments[1]);
var exp = method.Arguments[1];
where.Add(" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
SetTableShortName(result, queryable);
}
}
else if (method.Method.Name == "WhereIF")
{
var isOk = LambdaExpression.Lambda(method.Arguments[1]).Compile().DynamicInvoke();

View File

@@ -28,7 +28,11 @@ namespace SqlSugar
{
return new List<T>() { thisValue };
}
public static bool Any<T>(this IEnumerable<T> thisValue, IEnumerable<IConditionalModel> conditionalModels)
public static bool Any<T>(this IEnumerable<T> thisValue, List<IConditionalModel> conditionalModels)
{
throw new Exception("Can only be used in expressions");
}
public static IEnumerable<T> Where<T>(this IEnumerable<T> thisValue, List<IConditionalModel> conditionalModels)
{
throw new Exception("Can only be used in expressions");
}