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