Example #1
0
        private string AddJoin(JoinBase join)
        {
            var sb = new StringBuilder();

            var joinType = join.JoinType.ToString().ToUpperInvariant();

            sb.AppendLine()
            .Append(_level, joinType)
            .Append(" JOIN");

            if (join is JoinSubQueryOn joinSubQueryOn)
            {
                var subQb = new QueryBuilder();
                sb.AppendLine()
                .Append(_level + 1, "(")
                .Append(subQb.Build(joinSubQueryOn.SubQuery, _level + 1))
                .Append(") ")
                .Append(joinSubQueryOn.Alias);
            }
            else
            {
                sb.Append(' ')
                .Append(QueryHelper.GetSimplifiedSchemaAndTableName(join.Table.SchemaAndTableName))
                .Append(' ')
                .Append(join.Table.GetAlias());
            }
            sb.Append(" ON ");

            if (join is Join join2)
            {
                sb.Append(AddJoin(join2));
            }

            if (join is JoinOn joinOn)
            {
                sb.Append(AddJoinOn(joinOn));
            }

            return(sb.ToString());
        }
Example #2
0
 public Query Join(JoinBase join)
 {
     Joins.Add(join);
     QueryElements.Add(join);
     return(this);
 }