- 增加 HavingIf 方法;#1095

This commit is contained in:
2881099 2022-05-06 12:40:06 +08:00
parent 41432cde0a
commit ae1b053189
2 changed files with 9 additions and 1 deletions

View File

@ -19,11 +19,18 @@ namespace FreeSql
#endif
/// <summary>
/// 按聚合条件过滤,Where(a => a.Count() > 10)
/// 按聚合条件过滤,Having(a => a.Count() > 10)
/// </summary>
/// <param name="exp">lambda表达式</param>
/// <returns></returns>
ISelectGrouping<TKey, TValue> Having(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp);
/// <summary>
/// 按聚合条件过滤HavingIf(true, a => a.Count() > 10)
/// </summary>
/// <param name="condition">true 时生效</param>
/// <param name="exp">lambda表达式</param>
/// <returns></returns>
ISelectGrouping<TKey, TValue> HavingIf(bool condition, Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp);
/// <summary>
/// 按列排序OrderBy(a => a.Time)

View File

@ -226,6 +226,7 @@ namespace FreeSql.Internal.CommonProvider
return this;
}
public ISelectGrouping<TKey, TValue> HavingIf(bool condition, Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp) => condition ? Having(exp) : this;
public ISelectGrouping<TKey, TValue> Having(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp)
{
_lambdaParameter = exp?.Parameters[0];