Beispiel #1
0
        public override TSqlQuery Compile(ClauseCompilationContext context)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"{JoinType.GetDescription()} {TSqlSyntax.Join} {SqlBuilderHelper.PrepareTableName(JoinedTable)}");
            if (TableHints.HasValue)
            {
                string hints = SqlBuilderHelper.GetTableHintString(TableHints.Value);
                sb.Append(" ");
                sb.Append($"{TSqlSyntax.With}({hints})");
            }
            sb.Append(" ");
            sb.Append($"{TSqlSyntax.On} {LeftField.GetFullName()} {SqlBuilderHelper.ConvertBinaryOperationToString(Operation)} {RightField.GetFullName()}");

            return(new TSqlQuery(sb.ToString()));
        }
Beispiel #2
0
        public override TSqlQuery Compile(ClauseCompilationContext context)
        {
            string concatenatedFields = TSqlSyntax.AllFieldsSymbol;

            if (SelectItems != null & SelectItems.Any())
            {
                concatenatedFields = string.Join(
                    TSqlSyntax.FieldsDelimeter,
                    SelectItems.Select(f => f.Compile())
                    );
            }

            StringBuilder sb = new StringBuilder();

            sb.Append($"{TSqlSyntax.Select}");

            if (Distinct)
            {
                sb.Append(" ");
                sb.Append($"{TSqlSyntax.Distinct}");
            }
            if (topCount.HasValue)
            {
                sb.Append(" ");
                sb.Append($"{TSqlSyntax.Top} {topCount}");
            }
            sb.Append(" ");
            sb.Append($"{concatenatedFields} {TSqlSyntax.From} {SqlBuilderHelper.PrepareTableName(TableName)}");

            if (TableHints.HasValue)
            {
                string hints = SqlBuilderHelper.GetTableHintString(TableHints.Value);
                sb.Append(" ");
                sb.Append($"{TSqlSyntax.With}({hints})");
            }

            return(new TSqlQuery(sb.ToString()));
        }