From c80819aa4b623c07f1ab0f7e3483a35d1fd89bf8 Mon Sep 17 00:00:00 2001 From: Soar360 Date: Mon, 30 Oct 2023 15:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE=EF=BC=9AXC?= =?UTF-8?q?odeSetting.FastCountMin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XCode/Entity/EntitySession.cs | 3 ++- XCode/Setting.cs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/XCode/Entity/EntitySession.cs b/XCode/Entity/EntitySession.cs index b1a480ddc..c6c4140e8 100644 --- a/XCode/Entity/EntitySession.cs +++ b/XCode/Entity/EntitySession.cs @@ -474,7 +474,8 @@ private Int64 GetCount(Int64 count) } // 查真实记录数,修正FastCount不够准确的情况 - if (/*count >= 0 &&*/ count < 10_000_000) + var fastCountMin = XCodeSetting.Current.FastCountMin; + if (count < fastCountMin) { var builder = new SelectBuilder { diff --git a/XCode/Setting.cs b/XCode/Setting.cs index 671daf95e..f2cc69ec4 100644 --- a/XCode/Setting.cs +++ b/XCode/Setting.cs @@ -88,6 +88,10 @@ public class XCodeSetting : Config /// [Description("表名称、字段名大小写格式。Default 根据模型生成;Upper 全大写;Lower 全小写;Underline下划线")] public NameFormats NameFormat { get; set; } = NameFormats.Default; + + /// 快速统计最小数据量 + [Description("快速统计最小数据量。默认一千万,在对数据表进行无条件 count 时,先进行快速统计。如果快速统计的结果大于该值,则使用快速统计的结果。反之则进行 count(*) 操作获取精确统计。")] + public int FastCountMin { get; set; } = 10_000_000; #endregion #region 方法