

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

# Convertidores
<a name="converters"></a>

En algunos casos, puede que tenga que modificar o transformar los datos al guardar o leer datos de la base de datos de DynamoDB. [En esos casos, puede utilizar la interfaz de [IPropertyconversión](https://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/T_Amazon_DynamoDBv2_DataModel_IPropertyConverter.htm) de Amazon.Dynamo. DBv2 DataModel](https://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/N_Amazon_DynamoDBv2_DataModel.htm)espacio de nombres, mediante un código similar al siguiente:

```
   // Converts the null values of a string property to a valid string and vice versa.
    public class NullOrStringConverter : IPropertyConverter
    {
        // Called when creating the JSON / DynamoDB item from the model
        public DynamoDBEntry ToEntry(object value)
        {
            var entry = new Primitive
            {
                  value = new DynamoDBNull()
            };
            if(value != null)
            {
                  entry.Value = value.ToString();
            }
            return entry;
        }
       // Called when populating the model from the JSON / DynamoDB item
        public object FromEntry(DynamoDBEntry entry)
        {
            if(entry is DynamoDBNull)
            {
                  return string.Empty;
            }
            else
            {
                  return entry.ToString();
            }
        }
    }
```

Uso del convertidor en el modelo:

```
[DynamoDBTable(“AppLibrary")]
public class ProdApp
{
        . . .
 
        [DynamoDBProperty (typeof(NullOrString))]
        public string AppConfigId { get; set; }     
         . . . 
}
```