public DbQueryBase(ConnectionBuilder connectionBuilder, AbstractionOptions options) { this.connectionBuilder = connectionBuilder; this.Options = options; this.paginationFactory = PaginationAbstractFactory.GetObject(options.Dialect); this.exec = QueryExecutionLayerBuilder.Build(options, connectionBuilder); }
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); }
internal QueryPreProccess(AbstractionOptions options) { this.options = options; if (options.QueryParameterIdentifier == options.DialectParameterIdentifier) { this.PreProcessQuery = delegate(string s) { return(s); }; } else { this.PreProcessQuery = this.PreProcessQueyForDifferentIdentifiers; } if (options.SortQueryParameters) { this.PreProcessParameters = this.SortParamsFromQuery; } else { this.PreProcessParameters = delegate(string s, IEnumerable <DataBaseParameter> parameters) { return(parameters); }; } }
public QueryExecutionLayerWithLock(AbstractionOptions options, QueryPreProccess queryPreProcess, ConnectionBuilder connectionBuilder) { this.baseLayer = new QueryExecutionLayer(options, queryPreProcess, connectionBuilder); }
public DbQueryBase(IDbConnection connection, AbstractionOptions options) : this(new ConnectionBuilder(connection), options) { }
public QueryExecutionLayer(AbstractionOptions options, QueryPreProccess queryPreProcess, ConnectionBuilder connectionBuilder) { this.options = options; this.queryPreProcess = queryPreProcess; this.connectionBuilder = connectionBuilder; }