SQL 单引号和双引号同时存在处理
public static string OptimisedSql(this string strSqlOrExec)
{
if (string.IsNullOrWhiteSpace(strSqlOrExec))
{
return string.Empty;
}
//清空临时置换符号 (强制不出现字符)
strSqlOrExec = strSqlOrExec.Replace("+", "");
strSqlOrExec = strSqlOrExec.Replace("-", "");
//处理替换
strSqlOrExec = strSqlOrExec.Replace("'", "+");
strSqlOrExec = strSqlOrExec.Replace("''", "-");
//最终结果置换
strSqlOrExec = strSqlOrExec.Replace("+", "''");
strSqlOrExec = strSqlOrExec.Replace("-", "''''");
var result = strSqlOrExec;
return result;
}
定,精,简,俭