public DatasetSqlCompiler( ISqlCompiler compiler, IOptions <CompilerOptions> compOpts) { this.compiler = compiler; this.compilerOptions = compOpts.Value; }
public DemographicSqlCompiler( ISqlCompiler compiler, IOptions <CompilerOptions> compOpts) { this.compiler = compiler; this.compilerOptions = compOpts.Value; }
public ParallelPatientCohortService( ISqlCompiler compiler, PatientCountAggregator patientCountAggregator, IOptions <ClinDbOptions> clinOpts, ILogger <PatientCohortService> logger) : base(compiler, clinOpts, logger) { this.patientCountAggregator = patientCountAggregator; }
/// <summary> /// Creates a new instance of <see cref="BatchPlanner"/>. /// </summary> /// <param name="compiler">The <see cref="ISqlCompiler"/>.</param> /// <param name="hydrator">The <see cref="Hydrator"/>.</param> public BatchPlanner(ISqlCompiler compiler, Hydrator hydrator) { _compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); _hydrator = hydrator ?? throw new ArgumentNullException(nameof(hydrator)); _objectShaper = new ObjectShaper(new SqlAstValidator()); _arrayToConnectionConverter = new ArrayToConnectionConverter(); }
public static IEnumerable <SqlStatement> Parse(IContext context, SqlQuery query) { if (query == null) { throw new ArgumentNullException("query"); } ISqlCompiler compiler = null; if (context != null) { compiler = context.ResolveService <ISqlCompiler>(); } if (compiler == null) { compiler = new PlSqlCompiler(); } try { var compileContext = new SqlCompileContext(context, query.Text); var result = compiler.Compile(compileContext); if (result.HasErrors) { var messages = new StringBuilder(); messages.AppendFormat("SqlParseException for '{0}'" + Environment.NewLine, query.Text); foreach (var m in result.Messages) { messages.AppendFormat("Level: {0}", m.Level); if (null != m.Location) { messages.AppendFormat(", Line: {0}, Column: {1}", m.Location.Line, m.Location.Column); } messages.AppendFormat(", Message: {0}", m.Text); messages.AppendLine(); } throw new FormatException(messages.ToString()); } var statements = result.Statements; foreach (var statement in statements) { if (statement != null) { statement.SetSource(query); } } return(statements); } catch (Exception ex) { var messages = new StringBuilder(); messages.AppendFormat("The input string '{0}'" + Environment.NewLine, query.Text); messages.AppendFormat(" cannot be parsed into SQL Statements, because of {0}" + Environment.NewLine, ex.ToString()); throw new FormatException(messages.ToString(), ex); } }
protected PatientCohortService( ISqlCompiler compiler, IOptions <ClinDbOptions> clinOpts, ILogger <PatientCohortService> logger) { this.compiler = compiler; clinDbOptions = clinOpts.Value; log = logger; }
/// <summary> /// Creates a new instance of <see cref="JoinMonsterExecuter"/>. /// </summary> /// <param name="converter">The <see cref="QueryToSqlConverter"/>.</param> /// <param name="compiler">The <see cref="ISqlCompiler"/>.</param> /// <param name="batchPlanner">The <see cref="IBatchPlanner"/>.</param> /// <param name="hydrator">The <see cref="Hydrator"/>.</param> public JoinMonsterExecuter(QueryToSqlConverter converter, ISqlCompiler compiler, IBatchPlanner batchPlanner, Hydrator hydrator) { _converter = converter ?? throw new ArgumentNullException(nameof(converter)); _compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); _batchPlanner = batchPlanner ?? throw new ArgumentNullException(nameof(batchPlanner)); _hydrator = hydrator ?? throw new ArgumentNullException(nameof(hydrator)); _objectShaper = new ObjectShaper(new SqlAstValidator()); _arrayToConnectionConverter = new ArrayToConnectionConverter(); }
private static XSqlCommand GetCommand(ISqlCompiler Compiler, BaseSql Sql, string Bracket, string ParamPrefix) { var Params = new List <XSqlCommandParam>(); var ret = new XSqlCommand { CommandText = Sql.ToSQLString(Bracket, ParamPrefix, Params, Compiler) }; ret.Params = Params; var selectFields = new List <string>(); return(ret); }
public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { if (Params == null) { return(Name + "(" + string.Join(",", Arguments.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + ")"); } else { return(compiler.Compile(this.Clone(), Params)); } throw new NotImplementedException(); }
public PiecesCompiler(IEnumerable<IExpressionPiece> pieces, ISqlCompiler next) { _Next = next; _Pieces = pieces; }
void IServiceResolveContext.OnResolved(Type type, string name, object obj) { if (obj is ISqlCompiler) { sqlCompiler = (ISqlCompiler) obj; } else if (obj is IQueryPlanner) { queryPlanner = (IQueryPlanner) obj; } if (obj != null && obj is IConfigurable) ((IConfigurable)obj).Configure(Configuration); }
public static XSqlCommand GetCommand <T>(ISqlCompiler provider, IQueryable <T> sql) { return(GetCommand(provider, (BaseSql)sql, provider.GetBrackets(), provider.GetParamPrefix())); }
private static XSqlCommand GetCommand <T>(ISqlCompiler Compiler, IQueryable <T> Sql, string Bracket, string ParamPrefix) { return(GetCommand(Compiler, (BaseSql)Sql, Bracket, ParamPrefix)); }
public InTableCompiler(ITable table, IExpressionPiece piece, ISqlCompiler compiler) { _Table = table; _Piece = piece; _Compiler = compiler; }
public BetweenCompiler(ISqlCompiler parameterCompiler, ISqlCompiler secondParameter) { _SecondParameter = secondParameter; _FirstParameter = parameterCompiler; }
//[System.Diagnostics.DebuggerStepThrough] public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { var ret = ""; if (this.source == null) { if (SelectedFields == null || this.SelectedFields.Count == 0) { if (this.filter == null) { ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler); } else { ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } else { if (this.filter == null) { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler); } else { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } } else { if (SelectedFields == null || this.SelectedFields.Count == 0) { if (this.filter == null) { ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler); } else { ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } else { if (this.filter == null) { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler); } else { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } } if (this.GroupByFields != null) { ret += " Group By " + string.Join(",", this.GroupByFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))); } if (ret != "") { return(ret); } throw new NotImplementedException(); }
public SubQueryCompiler(ITable table, IEnumerable<IExpressionPiece> pieces, ISqlCompiler next) { var expressionPieces = pieces as List<IExpressionPiece> ?? pieces.ToList(); _Compiler = new PiecesCompiler(expressionPieces, new InTableCompiler(table, expressionPieces.Last(), next)); }
public LikeCompiler(ISqlCompiler firstParameter, WildCard token = WildCard.Both) { _Token = token; _FirstParameter = firstParameter; }
//[System.Diagnostics.DebuggerStepThrough] public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { if (this.Value != null) { return(this.Value.ToSQLString(Quotes, paramPrefix, Params)); } else if (this.Field != null) { return(this.Field.ToSQLString(Quotes, paramPrefix)); } else if (Op != null) { return("(" + Left.ToSQLString(Quotes, paramPrefix, Params, compiler) + ")" + Op + "(" + Right.ToSQLString(Quotes, paramPrefix, Params, compiler) + ") " + ((this.AliasName != null) ? string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), this.AliasName):"")); } else if (Callee != null) { if (Callee.AliasName == null) { return(Callee.ToSQLString(Quotes, paramPrefix, Params, compiler)); } else { return(Callee.ToSQLString(Quotes, paramPrefix, Params, compiler) + " " + string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), this.AliasName)); } } return("Unknown"); }
public static ISystemBuilder UseSqlCompiler(this ISystemBuilder builder, ISqlCompiler compiler) { return(builder.Use <ISqlCompiler>(options => options.With(compiler).InSystemScope())); }
public CtePatientCohortService( ISqlCompiler compiler, IOptions <ClinDbOptions> clinOpts, ILogger <PatientCohortService> logger) : base(compiler, clinOpts, logger) { }
private string GetFromClause(string quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { if (this.schema != null) { return(string.Format(string.Format("{0}{{0}}{1}.{0}{{1}}{1}", quotes[0], quotes[1]), this.schema, this.table)); } else { return(string.Format(string.Format("{0}{{0}}{1}", quotes[0], quotes[1]), this.table)); } }
public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { var ret = ""; if (this.LeftSource != null && this.RightSource != null) { if (this.JoinExpr == null) { ret = string.Join(",", new string[] { this.LeftSource.ToSQLString(Quotes, paramPrefix, Params, compiler), this.RightSource.ToSQLString(Quotes, paramPrefix, Params, compiler) }); } else { ret = this.LeftSource.ToSQLString(Quotes, paramPrefix, Params, compiler) + " " + this.JoinType + " join " + this.RightSource.ToSQLString(Quotes, paramPrefix, Params, compiler) + " on " + this.JoinExpr.ToSQLString(Quotes, paramPrefix, Params, compiler); } } if (Source != null) { if (Fields != null) { ret = string.Join(",", Fields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " from " + Source.ToSQLString(Quotes, paramPrefix, Params, compiler); ; } else { ret = Source.ToSQLString(Quotes, paramPrefix, Params, compiler); } } else if (Schema != null) { if (Fields != null) { ret = string.Join(",", Fields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " from " + string.Format(string.Format("{0}{{0}}{1}.{0}{{1}}{1}", Quotes[0], Quotes[1]), Schema, Table); ; } else { ret = string.Format(string.Format("{0}{{0}}{1}.{0}{{1}}{1}", Quotes[0], Quotes[1]), Schema, Table); ret = ret + " " + string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), Alias); return(ret); } } else if (Table != null) { if (Fields != null) { ret = string.Join(",", Fields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " from " + string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), Table); } else { ret = string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), Table); } } if (this.filter != null) { ret += " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } ret = ret + string.Format(string.Format("{0}{{0}}{1}", Quotes[0], Quotes[1]), Alias); if (this.Fields != null) { ret = "Select " + string.Join(",", this.Fields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " " + ret; } return("(" + ret + ")"); }