代码检查:替换为单次调用 Count(..)
此检查报告了使用 Where(...) 作为筛选器,然后立即调用 Count() 的 LINQ 查询。 相同的查询可以通过单次 Count(...) 调用变得更简洁、更清晰。
示例
int count = items.Where(x => x.IsActive).Count();
int count = items.Count(x => x.IsActive);
快速修复
将 Where(...).Count() 链替换为 Count(...)。
2026年 5月 8日