public static string GenerateOracleScriptToDebug(string queryString, IEnumerable <DataBaseParameter> parameters, char paramIdentifier = '@')
        {
            AbstractionOptions options = DefaultDialectOptions.GetDefaultOptions(DatabaseDialect.Oracle, false);

            options.QueryParameterIdentifier = paramIdentifier;

            QueryPreProccess preProccess = new QueryPreProccess(options);

            parameters = preProccess.PreProcessParameters(queryString, parameters);

            string newQuery = preProccess.PreProcessQuery(queryString);

            foreach (char c in "\n\t\r")
            {
                newQuery = newQuery.Replace(c, ' ');
            }
            newQuery = new Regex(" +").Replace(newQuery, " ");

            string output = $"  DECLARE \n    sql_query VARCHAR2({newQuery.Length + 2}) := '{newQuery}';\n";

            List <string> parametersNames = new List <string>();

            foreach (DataBaseParameter parameter in parameters)
            {
                if (parameter.Value is DateTime)
                {
                    DateTime dt = (DateTime)parameter.Value;
                    output += $"    {parameter.ParameterName} DATE := TO_DATE('{dt:yyyy-MM-dd HH:mm:ss}', 'YYYY-MM-DD HH24:MI:SS');\n";
                }
                else
                {
                    output += $"    {parameter.ParameterName} VARCHAR2({parameter.Value.ToString().Length}) := '{parameter.Value}';\n";
                }
                parametersNames.Add(parameter.ParameterName);
            }

            output += $"BEGIN\n     EXECUTE IMMEDIATE sql_query USING {string.Join(",", parametersNames.ToArray())};\n END;\n  /";
            return(output);
        }
示例#2
0
 public QueryExecutionLayerWithLock(AbstractionOptions options, QueryPreProccess queryPreProcess, ConnectionBuilder connectionBuilder)
 {
     this.baseLayer = new QueryExecutionLayer(options, queryPreProcess, connectionBuilder);
 }
 public QueryExecutionLayer(AbstractionOptions options, QueryPreProccess queryPreProcess, ConnectionBuilder connectionBuilder)
 {
     this.options           = options;
     this.queryPreProcess   = queryPreProcess;
     this.connectionBuilder = connectionBuilder;
 }