From 1e3afc225bd65f5d55382074947c5b8d1942fb3b Mon Sep 17 00:00:00 2001 From: tangjingtai Date: Fri, 5 Feb 2021 09:36:53 +0800 Subject: [PATCH] =?UTF-8?q?Where=E6=9D=A1=E4=BB=B6=E4=B8=AD=20xxx=20in(1,2?= =?UTF-8?q?,3)=E6=93=8D=E4=BD=9C=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=98=AF?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E7=B1=BB=E5=9E=8B=EF=BC=8C=E5=88=99=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=E6=95=B0=E5=AD=97=E4=BD=BF=E7=94=A8=E5=8D=95=E5=BC=95?= =?UTF-8?q?=E5=8F=B7=E6=8B=AC=E8=B5=B7=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SqlSugar/Utilities/DbExtensions.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs b/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs index 88db9e123..995dbacee 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/DbExtensions.cs @@ -15,10 +15,34 @@ namespace SqlSugar } else { - return string.Join(",", array.Where(c => c != null).Select(it => (it + "").ToSqlValue())); + return string.Join(",", array.Where(c => c != null).Select(it => it.ToSqlValue())); } } + /// + /// 数值类型 + /// + static Type[] NumericalTypes = new Type[] + { + typeof(int), + typeof(uint), + typeof(byte), + typeof(sbyte), + typeof(long), + typeof(ulong), + typeof(short), + typeof(ushort), + }; + + public static string ToSqlValue(this object value) + { + if (NumericalTypes.Contains(value.GetType())) + return value.ToString(); + + var str = value + ""; + return str.ToSqlValue(); + } + public static string ToSqlValue(this string value) { return string.Format("'{0}'", value.ToSqlFilter());