From cc7184785ece3885ca5accef33e5ac199bccfc74 Mon Sep 17 00:00:00 2001 From: cct0831 Date: Fri, 20 Mar 2026 22:51:23 +0800 Subject: [PATCH] refactor(core): collection expressions for Analysis DTOs and BasePagedListVM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace `new List()` property initializers with `[]` collection expressions: - AnalysisQueryRequest: Dimensions, Measures, Filters - AnalysisQueryResponse: Columns, Rows - ServerSideGroupByStrategy: empty list returns - BasePagedListVM: Ids First batch — remaining files deferred to follow-up. Closes #700 (partial) Co-Authored-By: Claude Opus 4.6 (1M context) --- src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryRequest.cs | 6 +++--- src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryResponse.cs | 4 ++-- .../Analysis/ServerSideGroupByStrategy.cs | 4 ++-- src/WalkingTec.Mvvm.Core/BasePagedListVM.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryRequest.cs b/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryRequest.cs index b234e877a..c932013a5 100644 --- a/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryRequest.cs +++ b/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryRequest.cs @@ -15,13 +15,13 @@ public class AnalysisQueryRequest public string? SearcherFormData { get; set; } /// 選取的維度欄位名稱(最多 3 個)。 - public List Dimensions { get; set; } = new List(); + public List Dimensions { get; set; } = []; /// 選取的度量及聚合函式。 - public List Measures { get; set; } = new List(); + public List Measures { get; set; } = []; /// 額外過濾條件(白名單驗證後進 Expression Tree)。 - public List Filters { get; set; } = new List(); + public List Filters { get; set; } = []; /// 維度對應的日期階層(僅日期維度需要,key=fieldName, value=hierarchy) public Dictionary? DimensionHierarchies { get; set; } diff --git a/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryResponse.cs b/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryResponse.cs index 6244f23be..a40585583 100644 --- a/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryResponse.cs +++ b/src/WalkingTec.Mvvm.Core/Analysis/AnalysisQueryResponse.cs @@ -9,10 +9,10 @@ namespace WalkingTec.Mvvm.Core.Analysis public class AnalysisQueryResponse { /// 欄位名稱清單(有序,對應 Rows 中的 key)。 - public List Columns { get; set; } = new List(); + public List Columns { get; set; } = []; /// 資料列(每列為 欄位名→值 的字典)。 - public List> Rows { get; set; } = new List>(); + public List> Rows { get; set; } = []; /// GroupBy 後總筆數。 public int TotalCount { get; set; } diff --git a/src/WalkingTec.Mvvm.Core/Analysis/ServerSideGroupByStrategy.cs b/src/WalkingTec.Mvvm.Core/Analysis/ServerSideGroupByStrategy.cs index cef23b598..c92e577cd 100644 --- a/src/WalkingTec.Mvvm.Core/Analysis/ServerSideGroupByStrategy.cs +++ b/src/WalkingTec.Mvvm.Core/Analysis/ServerSideGroupByStrategy.cs @@ -26,7 +26,7 @@ public class ServerSideGroupByStrategy : IGroupByStrategy CancellationToken cancellationToken = default) { if (req.Dimensions.Count == 0) - return new List>(); + return []; if (req.DimensionHierarchies != null && req.Dimensions.Any(d => req.DimensionHierarchies.TryGetValue(d, out var h) && h != DateHierarchy.None)) { @@ -51,7 +51,7 @@ public class ServerSideGroupByStrategy : IGroupByStrategy CancellationToken cancellationToken = default) { if (req.Dimensions.Count == 0) - return new List>(); + return []; if (req.DimensionHierarchies != null && req.Dimensions.Any(d => req.DimensionHierarchies.TryGetValue(d, out var h) && h != DateHierarchy.None)) { diff --git a/src/WalkingTec.Mvvm.Core/BasePagedListVM.cs b/src/WalkingTec.Mvvm.Core/BasePagedListVM.cs index 992100a06..13d152ccd 100644 --- a/src/WalkingTec.Mvvm.Core/BasePagedListVM.cs +++ b/src/WalkingTec.Mvvm.Core/BasePagedListVM.cs @@ -423,7 +423,7 @@ public SortInfo CreateSortInfo(Expression> pro, SortDir dir /// ///记录批量操作时列表中选择的Id /// - public List Ids { get; set; } = new List(); + public List Ids { get; set; } = []; public string? SelectorValueField { get; set; } /// /// 是否已经搜索过