protected virtual void GenerateTagsHeaderComment(SelectExpression selectExpression)
 {
     if (selectExpression.Tags.Count > 0)
     {
         foreach (var tag in selectExpression.Tags)
         {
             _relationalCommandBuilder
             .AppendLines(_sqlGenerationHelper.GenerateComment(tag))
             .AppendLine();
         }
     }
 }
示例#2
0
        private void GenerateFromSql(FromSqlExpression fromSqlExpression)
        {
            var sql = fromSqlExpression.Sql;

            string[] substitutions = null;

            switch (fromSqlExpression.Arguments)
            {
            case ConstantExpression constantExpression
                when constantExpression.Value is CompositeRelationalParameter compositeRelationalParameter:
            {
                var subParameters = compositeRelationalParameter.RelationalParameters;
                substitutions = new string[subParameters.Count];
                for (var i = 0; i < subParameters.Count; i++)
                {
                    substitutions[i] = _sqlGenerationHelper.GenerateParameterNamePlaceholder(subParameters[i].InvariantName);
                }

                _relationalCommandBuilder.AddParameter(compositeRelationalParameter);

                break;
            }
            }

            if (substitutions != null)
            {
                // ReSharper disable once CoVariantArrayConversion
                // InvariantCulture not needed since substitutions are all strings
                sql = string.Format(sql, substitutions);
            }


            _relationalCommandBuilder.AppendLines(sql);
        }
示例#3
0
        /// <summary>
        ///     Appends the given object to the command being built as multiple lines of text. That is,
        ///     each line in the passed object (as a string) is added as a line to the command being built.
        ///     This results in the lines having the correct indentation.
        /// </summary>
        /// <param name="o"> The object to append. </param>
        /// <returns> This builder so that additional calls can be chained. </returns>
        public virtual MigrationCommandListBuilder AppendLines([NotNull] object o)
        {
            Check.NotNull(o, nameof(o));

            _commandBuilder.AppendLines(o);

            return(this);
        }
        /// <summary>
        ///     Appends the given object to the command being built as multiple lines of text. That is,
        ///     each line in the passed string is added as a line to the command being built.
        ///     This results in the lines having the correct indentation.
        /// </summary>
        /// <param name="value"> The string to append. </param>
        /// <returns> This builder so that additional calls can be chained. </returns>
        public virtual MigrationCommandListBuilder AppendLines([NotNull] string value)
        {
            Check.NotNull(value, nameof(value));

            _commandBuilder.AppendLines(value);

            return(this);
        }
示例#5
0
        protected override Expression VisitFromSql(FromSqlExpression fromSqlExpression)
        {
            _relationalCommandBuilder.AppendLine("(");

            using (_relationalCommandBuilder.Indent())
            {
                _relationalCommandBuilder.AppendLines(fromSqlExpression.Sql);
                // TODO: Generate parameters
            }

            _relationalCommandBuilder.Append(") AS ")
            .Append(_sqlGenerationHelper.DelimitIdentifier(fromSqlExpression.Alias));

            return(fromSqlExpression);
        }