- 优化 GroupBy 聚合函数 Count(bool) 解析成 sum(case when);#1841

This commit is contained in:
2881099
2024-07-02 23:41:03 +08:00
parent a5d7595647
commit 36af40a868
3 changed files with 16 additions and 111 deletions

View File

@ -619,7 +619,18 @@ namespace base_entity
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion
var sqlc001 = fsql.Select<User1>()
.GroupBy(a => a.GroupId)
.ToSql(g => new
{
cou1 = g.Count(),
cou2 = g.Count(g.Value.Nickname),
cou3 = g.Count(g.Value.Nickname == "xx"),
cou4 = g.Count(g.Value.Sort > 50),
cou5 = g.Count(g.Value.Sort > 50 || g.Value.Username == "xx"),
});
fsql.Select<Account>().As("aaa").Where(p => p.ID == 1).AsQueryable().Distinct().Select(p => new { p.Name, p.ID }).Count();