From 63a8e8ec28a8acd17825e508c43d86f77b1cb613 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Fri, 22 Mar 2024 11:59:37 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20IUpdate.SetSource=20Sq?= =?UTF-8?q?lServer=20=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0=20Cast=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B#1755?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SqlServer/Curd/CustomSqlServerUpdate.cs | 4 ++-- .../SqlServer/Curd/OdbcSqlServerUpdate.cs | 4 ++-- Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs b/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs index dc02dfcae..3811c04d8 100644 --- a/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.Custom/SqlServer/Curd/CustomSqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } } diff --git a/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs b/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs index c0a07c188..b131cf71a 100644 --- a/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.Odbc/SqlServer/Curd/OdbcSqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } } diff --git a/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs b/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs index 1dd7a5e0a..ae4710db4 100644 --- a/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs +++ b/Providers/FreeSql.Provider.SqlServer/Curd/SqlServerUpdate.cs @@ -90,7 +90,7 @@ protected override void ToSqlCase(StringBuilder caseWhen, ColumnInfo[] primarys) foreach (var pk in primarys) { if (pkidx > 0) caseWhen.Append(" + '+' + "); - caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar)"); + caseWhen.Append("cast(").Append(_commonUtils.RereadColumn(pk, _commonUtils.QuoteSqlName(pk.Attribute.Name))).Append(" as varchar(2000))"); ++pkidx; } caseWhen.Append(")"); @@ -107,7 +107,7 @@ protected override void ToSqlWhen(StringBuilder sb, ColumnInfo[] primarys, objec foreach (var pk in primarys) { if (pkidx > 0) sb.Append(" + '+' + "); - sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)"); + sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar(2000))"); ++pkidx; } }