mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Where条件中 xxx in(1,2,3)操作,如果是数值类型,则不对数字使用单引号括起来
This commit is contained in:
parent
e155259e78
commit
1e3afc225b
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user