From af34ed845c14224803019cb7b796a875482e1f1a Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Thu, 12 Dec 2024 19:51:13 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=20SqlServer=20WithIndex?= =?UTF-8?q?=20=E4=BD=BF=E7=94=A8=E4=B9=A0=E6=83=AF=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs b/Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs index 5dc4a8560..646f8a6ff 100644 --- a/Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs +++ b/Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs @@ -119,7 +119,7 @@ static TReturn LocalWithLock(TReturn query, SqlServerLock lockType, Dic static TReturn LocalWithIndex(TReturn query, string indexName, Dictionary rule) { - if (string.IsNullOrWhiteSpace(indexName)) return query; + if (string.IsNullOrWhiteSpace(indexName) && rule?.Any() != true) return query; var selectProvider = query as Select0Provider; switch (selectProvider._orm.Ado.DataType) { @@ -134,7 +134,7 @@ static TReturn LocalWithIndex(TReturn query, string indexName, Dictiona selectProvider._aliasRule = (type, old) => { if (oldalias != null) old = oldalias(type, old); - if (type == selectProvider._tables[0].Table.Type) return LocalAppendWithString(old, $"index={indexName}"); + if (string.IsNullOrWhiteSpace(indexName) == false && type == selectProvider._tables[0].Table.Type) return LocalAppendWithString(old, $"index={indexName}"); if (rule == null) return old; return rule.TryGetValue(type, out var tryidxName) && string.IsNullOrWhiteSpace(tryidxName) == false ? LocalAppendWithString(old, $"index={tryidxName}") : old; };