Esempio n. 1
0
        public static string replaceParamsInQuery(StringBuilder query, Dictionary<string,string> param)
        {
            var rexStart = "@";//(?<=@)";
            var rexEnd = "(?=[\\s|,|\\)|$])";
            //var rex = new System.Text.RegularExpressions.Regex("(?<=@)\\w*");

            var sqry = query.ToString() + " "; // HACK: adding space as parameters at the end of the string were not being matched
            foreach(var p in param.Keys)
            {
                sqry = new Regex(string.Format("{0}{1}{2}", rexStart, p, rexEnd), RegexOptions.Singleline| RegexOptions.IgnoreCase)
                    .Replace(sqry,"\"" + param[p] + "\"");
                //query.Replace(string.Format("@{0}",p), string.Format("\"{0}\"", param[p]));
            }

            //return query.ToString().Trim();
            return sqry.TrimEnd();
        }