public void FieldColumn(string fieldName, string fieldTypeName, Action <CreateColumnCommand> column = null) { var type = _dynamicAssemblyBuilder.GetFieldType(fieldTypeName); if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = Nullable.GetUnderlyingType(type); } var dbType = SchemaUtils.ToDbType(type); var command = new CreateColumnCommand(_tableCommand.Name, fieldName); command.WithType(dbType); if (column != null) { column(command); } _tableCommand.TableCommands.Add(command); }
public void CreateColumn(string tableName, string columnName, string columnType) { string formatedTableName = string.Format(TableFormat, tableName); bool result = CheckTableColumnExists(formatedTableName, columnName); if (result) { return; } var type = _dynamicAssemblyBuilder.GetFieldType(columnType); if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = Nullable.GetUnderlyingType(type); } var dbType = SchemaUtils.ToDbType(type); _schemaBuilder.AlterTable(string.Format(TableFormat, tableName), table => table.AddColumn(columnName, dbType)); GenerationDynmicAssembly(); }