public string GetUpdateQuery(QueryInformation predicateQueryInfo, QueryInformation modificationQueryInfo) { var msql = modificationQueryInfo.WhereSql.Replace("WHERE ", ""); var indexOfAnd = msql.IndexOf("AND", StringComparison.OrdinalIgnoreCase); var update = indexOfAnd == -1 ? msql : msql.Substring(0, indexOfAnd).Trim(); var updateRegex = new Regex(@"(\[[^\]]+\])[^=]+=(.+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); var match = updateRegex.Match(update); string updateSql; if (match.Success) { var col = match.Groups[1]; var rest = match.Groups[2].Value; rest = SqlStringHelper.FixParantheses(rest); updateSql = $"{col.Value} = {rest}"; } else { updateSql = string.Join(" = ", update.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries).Reverse()); } return($"UPDATE [{predicateQueryInfo.Schema}].[{predicateQueryInfo.Table}] SET {updateSql} {predicateQueryInfo.WhereSql}"); }