using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace Ant.Core.SqlServer { public static class QueryableExtensions { /// /// 根据第三方条件是否为真来决定是否执行指定条件的查询 /// /// 要查询的源 /// 查询条件 /// 第三方条件 /// 动态类型 /// 查询的结果 public static IQueryable WhereIf(this IQueryable source, bool condition, Expression> predicate) { return condition ? source.Where(predicate) : source; } } }