From d583fd8352eee39b6464d8793148a343e547d7b8 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 12 Jun 2023 15:55:44 +0800 Subject: [PATCH] Update sqlserver first distinct --- .../Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs index 1f4819753..a0417bafb 100644 --- a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerQueryBuilder.cs @@ -104,6 +104,10 @@ namespace SqlSugar this.OldSql += this.Offset; } result = GetSqlQuerySql(result); + if (isFirst && IsDistinct) + { + result = result.Replace("TOP 1 DISTINCT", "TOP 1 "); + } return result; }