标签:ble blog and ssi code any using query lam
原文:https://www.cnblogs.com/Lau7/p/5451985.html
public static class ExpressionExt
{
public static Expression<Func<T, bool>> And<T>(this?Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2)
{
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(expr1.Body, expr2.Body), expr1.Parameters);
}
public static Expression<Func<T, bool>> Or<T>(this?Expression<Func<T, bool>> expr1,Expression<Func<T, bool>> expr2)
{
return Expression.Lambda<Func<T, bool>>(Expression.OrElse(expr1.Body, expr2.Body), expr1.Parameters);
}
}
Expression<Func<SysUser, bool>> exp1 = s => s.UserName.Contains("1") && s.Age > 0;
Expression<Func<SysUser, bool>> exp2 =exp1.And( s => s.IsEnable == 1);
using (var context = new DbContext().ConnectionString(connString))
{
var result1 = context.Select<SysUser>(exp1).QueryMany();
var result2 = context.Select<SysUser>(exp2).QueryMany();
}
标签:ble blog and ssi code any using query lam
原文地址:https://www.cnblogs.com/guxingy/p/13207203.html