diff --git a/Group-Aggregation-Query.md b/Group-Aggregation-Query.md index 86cef92..7c91cce 100644 --- a/Group-Aggregation-Query.md +++ b/Group-Aggregation-Query.md @@ -46,6 +46,16 @@ var list = fsql.Select() > To find the aggregate value without grouping, please use `ToAggregate` instead of `ToList` +```csharp +var list = fsql.Select() + .ToAggregate(a => new + { + cou1 = a.Count(), + arg1 = a.Avg(a.Value.Clicks), + arg2 = a.Sum(a.Value.Clicks > 100 ? 1 : 0) + }); +``` + ## Navigation Property Grouping If `Topic` has the navigation property `Category`, and `Category` has the navigation property `Area`, the navigation property grouping code is as follows: diff --git a/分组聚合查询.md b/分组聚合查询.md index 9e029c1..bc8fbec 100644 --- a/分组聚合查询.md +++ b/分组聚合查询.md @@ -45,6 +45,16 @@ var list = fsql.Select() > 不分组求聚合值,请使用 ToAggregate 替代 ToList +```csharp +var list = fsql.Select() + .ToAggregate(a => new + { + cou1 = a.Count(), + arg1 = a.Avg(a.Value.Clicks), + arg2 = a.Sum(a.Value.Clicks > 100 ? 1 : 0) + }); +``` + ## 导航属性分组 假如 Topic 有导航属性 Category,Category 又有导航属性 Area,导航属性分组代码如下: