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());