using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
|
namespace JiepeiWMS.Extends
|
{
|
/// <summary>
|
/// 数值扩展
|
/// </summary>
|
public static class ExtString
|
{
|
#region Sql转换
|
/// <summary>
|
/// 转换成SQL字符串
|
/// </summary>
|
/// <param name="Value">字符串</param>
|
/// <returns>SQL字符串</returns>
|
public static string _ToSqlStr(this string Value)
|
{
|
return Value.Replace("'", "''");
|
}
|
/// <summary>
|
/// 转换成SQL Like条件查询字符串(非法字符会被过滤掉)
|
/// </summary>
|
/// <param name="Value">字符串</param>
|
/// <returns>SQL Like条件查询字符串</returns>
|
public static string _ToSqlLikeStr(this string Value)
|
{
|
var likestr = Value._ToSqlStr().Replace("[", "[[]").Replace("%", "[%]").Replace("_", "[_]");
|
return likestr;
|
}
|
/// <summary>
|
/// 转换成SQL字段名(非法字符会被过滤掉)
|
/// </summary>
|
/// <param name="Value">字符串</param>
|
/// <returns>SQL字段名</returns>
|
public static string _ToSqlFieldStr(this string Value)
|
{
|
return Regex.Replace(Value, @"[^\w,]+", "");
|
}
|
#endregion
|
|
}
|
|
}
|