Mysql特殊字符处理

public static class MysqlSpecialCharactersHelper
    {
        /// <summary>
        /// Mysql特殊字符处理
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string SpecialCharactersTransfer(this string source)
        {
            source = source.Replace(@"\", @"\\\\\");
            source = source.Replace(@"'", @"\'");
            source = source.Replace(@"_", @"\_");
            source = source.Replace(@"%", @"\%");
            return source;
        }
    }

 

posted @ 2020-04-08 10:47  LXMZQ  阅读(483)  评论(0编辑  收藏  举报