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);