internal BuiltQuery Build(QueryBuilderContext context) { var sb = new StringBuilder(); var current = this; while (current != null) { if (!current.Include) { // move on current = current.Parent; continue; } var queryPart = current.ToString(context); var emptyQueryPart = string.IsNullOrEmpty(queryPart); if (!emptyQueryPart) { sb.Insert(0, queryPart); } current = current.Parent; if (current != null && !emptyQueryPart) { sb.Insert(0, MsSql.StatementSeparator); } } return(new BuiltQuery(sb.ToString(), context.GetParameters())); }
public override string ToString(QueryBuilderContext context) { var sql = $"{MsSql.OrderBy}{MsSql.StatementSeparator}{Expression}"; if (!string.IsNullOrEmpty(Sorting)) { sql = $"{sql}{MsSql.StatementSeparator}{Sorting}"; } return(sql); }
public override string ToString(QueryBuilderContext context) { var hasOperator = Operator != null; var value = hasOperator ? context.AddParameter(Value) : null; return($"{Expression}" + $"{(hasOperator ? MsSql.StatementSeparator : string.Empty)}" + $"{Operator ?? string.Empty}" + $"{(hasOperator ? MsSql.StatementSeparator : string.Empty)}" + $"{value ?? string.Empty}"); }
public override string ToString(QueryBuilderContext context) { return($"({_scopedQuery.Build(context).Query})"); }
public override string ToString(QueryBuilderContext context) { var builtQuery = SubQuery.Build(context); return($"{MsSql.Where}{MsSql.StatementSeparator}{builtQuery.Query}"); }
public override string ToString(QueryBuilderContext context) { return($"{MsSql.From}{MsSql.StatementSeparator}{Expression}"); }
public override string ToString(QueryBuilderContext context) { return(Expression); }
public override string ToString(QueryBuilderContext context) { return($"{JoinType}{MsSql.StatementSeparator}{JoinSource}{MsSql.StatementSeparator}{MsSql.On}{MsSql.StatementSeparator}{JoinCondition}"); }
public abstract string ToString(QueryBuilderContext context);
public BuiltQuery Build() { var context = new QueryBuilderContext(); return(Build(context)); }