mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-03 15:00:53 +08:00
update
13
分组聚合查询.md
13
分组聚合查询.md
@@ -61,6 +61,19 @@ var list = fsql.Select<Topic>()
|
||||
.ToList(a => new { a.Key.Area.Name });
|
||||
```
|
||||
|
||||
## 多表分组
|
||||
|
||||
```c#
|
||||
var list = fsql.Select<Topic, Category, Area>()
|
||||
.GroupBy((a, b, c) => new { a.Title, c.Name })
|
||||
.Having(g => g.Count() < 300 || g.Avg(g.Value.Item1.Clicks) < 100)
|
||||
.ToList(g => new { count = g.Count(), Name = g.Key.Name });
|
||||
```
|
||||
|
||||
- g.Value.Item1 对应 Topic
|
||||
- g.Value.Item2 对应 Category
|
||||
- g.Value.Item3 对应 Area
|
||||
|
||||
## Aggregate
|
||||
|
||||
```c#
|
||||
|
||||
Reference in New Issue
Block a user