src/Shared/EntityFramework/Migrations/Design/CSharpMigrationCodeGenerator.cs
/// <summary>Generates code to specify the definition for a <see cref="T:System.Data.Entity.Migrations.Model.ParameterModel" />.</summary>
/// <param name="parameterModel">The parameter definition to generate code for.</param>
/// <param name="writer">Text writer to add the generated code to.</param>
/// <param name="emitName">A value indicating whether to include the column name in the definition.</param>
Generates code to specify the definition for a .
Generates code to specify the definition for a .
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")]
        [SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
        protected virtual void Generate(ParameterModel parameterModel, IndentedTextWriter writer, bool emitName = false)
        {
            Check.NotNull(parameterModel, "parameterModel");
            Check.NotNull(writer, "writer");
            writer.Write(" p.");
            writer.Write(TranslateColumnType(parameterModel.Type));
            writer.Write("(");
            var args = new List<string>();
            if (emitName)
            {
                args.Add("name: " + Quote(parameterModel.Name));
            }
            if (parameterModel.MaxLength != null)
            {
                args.Add("maxLength: " + parameterModel.MaxLength);
            }
            if (parameterModel.Precision != null)
            {
                args.Add("precision: " + parameterModel.Precision);
            }
            if (parameterModel.Scale != null)
            {
                args.Add("scale: " + parameterModel.Scale);
            }
            if (parameterModel.IsFixedLength != null)
            {
                args.Add("fixedLength: " + parameterModel.IsFixedLength.ToString().ToLowerInvariant());
            }
            if (parameterModel.IsUnicode != null)
            {
                args.Add("unicode: " + parameterModel.IsUnicode.ToString().ToLowerInvariant());
            }
            if (parameterModel.DefaultValue != null)
            {
#if NETSTANDARD
                args.Add("defaultValue: " + GenerateDefaultValueByType(parameterModel.DefaultValue));
#else
                args.Add("defaultValue: " + Generate((dynamic)parameterModel.DefaultValue));
#endif
            }
            if (!string.IsNullOrWhiteSpace(parameterModel.DefaultValueSql))
            {
                args.Add("defaultValueSql: " + Quote(parameterModel.DefaultValueSql));
            }
            if (!string.IsNullOrWhiteSpace(parameterModel.StoreType))
            {
                args.Add("storeType: " + Quote(parameterModel.StoreType));
            }
            if (parameterModel.IsOutParameter)
            {
                args.Add("outParameter: true");
            }
            writer.Write(args.Join());
            writer.Write(")");
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] protected virtual void Generate ( ParameterModel parameterModel , IndentedTextWriter writer , bool emitName = false ) { Check . NotNull ( parameterModel , " " ) ; Check . NotNull ( writer , " " ) ; writer . Write ( " " ) ; writer . Write ( TranslateColumnType ( parameterModel . Type ) ) ; writer . Write ( " " ) ; var args = new List < string > ( ) ; if ( emitName ) { args . Add ( " " + Quote ( parameterModel . Name ) ) ; } if ( parameterModel . MaxLength != null ) { args . Add ( " " + parameterModel . MaxLength ) ; } if ( parameterModel . Precision != null ) { args . Add ( " " + parameterModel . Precision ) ; } if ( parameterModel . Scale != null ) { args . Add ( " " + parameterModel . Scale ) ; } if ( parameterModel . IsFixedLength != null ) { args . Add ( " " + parameterModel . IsFixedLength . ToString ( ) . ToLowerInvariant ( ) ) ; } if ( parameterModel . IsUnicode != null ) { args . Add ( " " + parameterModel . IsUnicode . ToString ( ) . ToLowerInvariant ( ) ) ; } if ( parameterModel . DefaultValue != null ) { if NETSTANDARD args . Add ( " " + GenerateDefaultValueByType ( parameterModel . DefaultValue ) ) ; else args . Add ( " " + Generate ( ( dynamic ) parameterModel . DefaultValue ) ) ; endif } if ( ! string . IsNullOrWhiteSpace ( parameterModel . DefaultValueSql ) ) { args . Add ( " " + Quote ( parameterModel . DefaultValueSql ) ) ; } if ( ! string . IsNullOrWhiteSpace ( parameterModel . StoreType ) ) { args . Add ( " " + Quote ( parameterModel . StoreType ) ) ; } if ( parameterModel . IsOutParameter ) { args . Add ( " " ) ; } writer . Write ( args . Join ( ) ) ; writer . Write ( " " ) ; }
Generates code to specify the definition for a .
Generates code to specify the definition for a .
parameterModel
ParameterModel
The parameter definition to generate code for.
The parameter definition to generate code for .
writer
IndentedTextWriter
Text writer to add the generated code to.
Text writer to add the generated code to .
emitName
bool
A value indicating whether to include the column name in the definition.
A value indicating whether to include the column name in the definition .