Exemplo n.º 1
0
        protected virtual void GenerateAnnotation(
            [NotNull] IAnnotation annotation, [NotNull] IndentedStringBuilder stringBuilder)
        {
            Check.NotNull(annotation, nameof(annotation));
            Check.NotNull(stringBuilder, nameof(stringBuilder));

            stringBuilder
            .Append(".Annotation(")
            .Append(_code.Literal(annotation.Name))
            .Append(", ")
            .Append(_code.UnknownLiteral(annotation.Value))
            .Append(")");
        }
        protected virtual void Generate([NotNull] AddColumnOperation operation, [NotNull] IndentedStringBuilder builder)
        {
            Check.NotNull(operation, nameof(operation));
            Check.NotNull(builder, nameof(builder));

            builder
            .Append(".AddColumn<")
            .Append(_code.Reference(operation.ClrType))
            .AppendLine(">(");

            using (builder.Indent())
            {
                builder
                .Append("name: ")
                .Append(_code.Literal(operation.Name));

                if (operation.Schema != null)
                {
                    builder
                    .AppendLine(",")
                    .Append("schema: ")
                    .Append(_code.Literal(operation.Schema));
                }

                builder
                .AppendLine(",")
                .Append("table: ")
                .Append(_code.Literal(operation.Table));

                if (operation.ColumnType != null)
                {
                    builder
                    .AppendLine(",")
                    .Append("type: ")
                    .Append(_code.Literal(operation.ColumnType));
                }

                builder.AppendLine(",")
                .Append("nullable: ")
                .Append(_code.Literal(operation.IsNullable));

                if (operation.DefaultValueSql != null)
                {
                    builder
                    .AppendLine(",")
                    .Append("defaultValueSql: ")
                    .Append(_code.Literal(operation.DefaultValueSql));
                }
                else if (operation.ComputedColumnSql != null)
                {
                    builder
                    .AppendLine(",")
                    .Append("computedColumnSql: ")
                    .Append(_code.UnknownLiteral(operation.ComputedColumnSql));
                }
                else if (operation.DefaultValue != null)
                {
                    builder
                    .AppendLine(",")
                    .Append("defaultValue: ")
                    .Append(_code.UnknownLiteral(operation.DefaultValue));
                }

                builder.Append(")");

                Annotations(operation.Annotations, builder);
            }
        }