Skip to content

Commit 6d1059a

Browse files
committed
- 忧化 GroupBySelf.Where 自动转 having;
1 parent 9d10c70 commit 6d1059a

File tree

3 files changed

+193
-0
lines changed

3 files changed

+193
-0
lines changed

FreeSql/FreeSql.xml

Lines changed: 190 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ public TSelect AsType(Type entityType)
10321032
public TSelect WhereIf(bool condition, string sql, object parms = null)
10331033
{
10341034
if (condition == false || string.IsNullOrEmpty(sql)) return this as TSelect;
1035+
if (_groupBySelfFlag) return this.Having(sql, parms);
10351036
_where.Append(" AND (").Append(sql).Append(")");
10361037
if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms));
10371038
return this as TSelect;

FreeSql/Internal/CommonProvider/SelectProvider/Select0ProviderReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,10 @@ public ISelectGrouping<TKey, TValue> InternalGroupBy<TKey, TValue>(Expression co
851851
this.GroupBy(sql.Length > 0 ? sql.Substring(2) : null);
852852
return new SelectGroupingProvider<TKey, TValue>(_orm, this, map, sql, _commonExpression, _tables);
853853
}
854+
bool _groupBySelfFlag = false;
854855
public TSelect InternalGroupBySelf(Expression column)
855856
{
857+
_groupBySelfFlag = true;
856858
if (column.NodeType == ExpressionType.Lambda) column = (column as LambdaExpression)?.Body;
857859
switch (column?.NodeType)
858860
{

0 commit comments

Comments
 (0)