Skip to content

Commit

Permalink
- 优化 SqlServer WithIndex 使用习惯;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 12, 2024
1 parent cb10351 commit af34ed8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Providers/FreeSql.Provider.SqlServer/SqlServerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static TReturn LocalWithLock<TReturn>(TReturn query, SqlServerLock lockType, Dic

static TReturn LocalWithIndex<TReturn>(TReturn query, string indexName, Dictionary<Type, string> 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)
{
Expand All @@ -134,7 +134,7 @@ static TReturn LocalWithIndex<TReturn>(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;
};
Expand Down

0 comments on commit af34ed8

Please sign in to comment.