mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-05 03:17:41 +08:00
Update exp to sql
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
@@ -49,6 +50,18 @@ namespace SqlSugar
|
|||||||
return Expression.Equal(left, Expression.Convert(value, left.Type));
|
return Expression.Equal(left, Expression.Convert(value, left.Type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static Expression CreateExpressionLike<ColumnType>(Type entityType,string propertyName,List<ColumnType> 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<Func<T, object>> CreateNewFields<T>(EntityInfo entity,List<string> propertyNames)
|
public static Expression<Func<T, object>> CreateNewFields<T>(EntityInfo entity,List<string> propertyNames)
|
||||||
{
|
{
|
||||||
Type sourceType = typeof(T);
|
Type sourceType = typeof(T);
|
||||||
|
|||||||
Reference in New Issue
Block a user