From 4fd4b42e74b634e2c4421bc6417ba2541dd562cc Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 20 Dec 2022 20:56:11 +0800 Subject: [PATCH] Update exp to sql --- .../SqlSugar/Utilities/ExpressionBuilderHelper.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Utilities/ExpressionBuilderHelper.cs b/Src/Asp.NetCore2/SqlSugar/Utilities/ExpressionBuilderHelper.cs index f375425ef..0eee3b073 100644 --- a/Src/Asp.NetCore2/SqlSugar/Utilities/ExpressionBuilderHelper.cs +++ b/Src/Asp.NetCore2/SqlSugar/Utilities/ExpressionBuilderHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -49,6 +50,18 @@ namespace SqlSugar return Expression.Equal(left, Expression.Convert(value, left.Type)); } } + public static Expression CreateExpressionLike(Type entityType,string propertyName,List list) + { + var parameter = Expression.Parameter(entityType, "p"); + MemberExpression memberProperty = Expression.PropertyOrField(parameter, propertyName); + MethodInfo method = typeof(List<>).MakeGenericType(typeof(ColumnType)).GetMethod("Contains"); + ConstantExpression constantCollection = Expression.Constant(list); + + MethodCallExpression methodCall = Expression.Call(constantCollection, method, memberProperty); + + var expression = Expression.Lambda(methodCall, parameter); + return expression; + } public static Expression> CreateNewFields(EntityInfo entity,List propertyNames) { Type sourceType = typeof(T);