Show / Hide Table of Contents

Class DynamoSerializer

The DynamoSerializer static class provides methods for (de)serializing values to/from DynamoDB attribute values. The following list shows the default type mapping for DynamoDB attribute values:

  • Numberint, int?, long, long?, double, double?, decimal, decimal?, DateTimeOffset, DateTimeOffset?
  • Stringstring, enum
  • Binarybyte[]
  • Booleanbool, bool?
  • Nullany nullable type
  • ListList<T>
  • MapDictionary<string, object>, Dictionary<string, T>, T
  • String SetISet<string>
  • Number SetISet<int>, ISet<long>, ISet<double>, ISet<decimal>
  • Binary SetISet<byte[]>
Inheritance
System.Object
DynamoSerializer
Namespace: LambdaSharp.DynamoDB.Serialization
Assembly: LambdaSharp.DynamoDB.Serialization.dll
Syntax
public static class DynamoSerializer

Methods

Deserialize(AttributeValue, Type)

The Deserialize(AttributeValue, Type) method deserializes a DynamoDB attribute value into a targetType instance using the default DynamoSerializerOptions instance.

Declaration
public static object Deserialize(AttributeValue attribute, Type targetType)
Parameters
Type Name Description
Amazon.DynamoDBv2.Model.AttributeValue attribute

The DynamoDB attribute value to deserialize.

System.Type targetType

The type to deserialize into.

Returns
Type Description
System.Object

An instance of targetType or null when the DynamoDB attribute value is NULL.

Deserialize(AttributeValue, Type, DynamoSerializerOptions)

The Deserialize(AttributeValue, Type, DynamoSerializerOptions) method deserializes a DynamoDB attribute value into a targetType instance.

Declaration
public static object Deserialize(AttributeValue attribute, Type targetType, DynamoSerializerOptions options)
Parameters
Type Name Description
Amazon.DynamoDBv2.Model.AttributeValue attribute

The DynamoDB attribute value to deserialize.

System.Type targetType

The type to deserialize into.

DynamoSerializerOptions options

The deserialization options to use.

Returns
Type Description
System.Object

An instance of targetType or null when the DynamoDB attribute value is NULL.

Deserialize(Dictionary<String, AttributeValue>, Type)

The Deserialize(Dictionary<String, AttributeValue>, Type) method deserializes a DynamoDB document into a targetType instance using the default DynamoSerializerOptions instance.

Declaration
public static object Deserialize(Dictionary<string, AttributeValue> document, Type targetType)
Parameters
Type Name Description
System.Collections.Generic.Dictionary<System.String, Amazon.DynamoDBv2.Model.AttributeValue> document

The DynamoDB document to deserialize.

System.Type targetType

The type to deserialize into.

Returns
Type Description
System.Object

An instance of targetType or null when the DynamoDB document is null.

Deserialize(Dictionary<String, AttributeValue>, Type, DynamoSerializerOptions)

The Deserialize(Dictionary<String, AttributeValue>, Type, DynamoSerializerOptions) method deserializes a DynamoDB document into a targetType instance.

Declaration
public static object Deserialize(Dictionary<string, AttributeValue> document, Type targetType, DynamoSerializerOptions options)
Parameters
Type Name Description
System.Collections.Generic.Dictionary<System.String, Amazon.DynamoDBv2.Model.AttributeValue> document

The DynamoDB document to deserialize.

System.Type targetType

The type to deserialize into.

DynamoSerializerOptions options

The deserialization options to use.

Returns
Type Description
System.Object

An instance of targetType or null when the DynamoDB document is null.

Deserialize<TRecord>(Dictionary<String, AttributeValue>)

The Deserialize<TRecord>(Dictionary<String, AttributeValue>) method deserializes a DynamoDB document into a TRecord instance using the default DynamoSerializerOptions instance.

Declaration
public static TRecord Deserialize<TRecord>(Dictionary<string, AttributeValue> document)
    where TRecord : class
Parameters
Type Name Description
System.Collections.Generic.Dictionary<System.String, Amazon.DynamoDBv2.Model.AttributeValue> document

The DynamoDB document to deserialize.

Returns
Type Description
TRecord

An instance of TRecord or null when the DynamoDB document is null.

Type Parameters
Name Description
TRecord

The type to deserialize into.

Deserialize<TRecord>(Dictionary<String, AttributeValue>, DynamoSerializerOptions)

The Deserialize<TRecord>(Dictionary<String, AttributeValue>, DynamoSerializerOptions) method deserializes a DynamoDB document into a TRecord instance.

Declaration
public static TRecord Deserialize<TRecord>(Dictionary<string, AttributeValue> document, DynamoSerializerOptions options)
    where TRecord : class
Parameters
Type Name Description
System.Collections.Generic.Dictionary<System.String, Amazon.DynamoDBv2.Model.AttributeValue> document

The DynamoDB document to deserialize.

DynamoSerializerOptions options

The deserialization options to use.

Returns
Type Description
TRecord

An instance of TRecord or null when the DynamoDB document is null.

Type Parameters
Name Description
TRecord

The type to deserialize into.

Serialize(Object)

The Serialize(Object) method serializes an object to a DynamoDB attribute value using the default DynamoSerializerOptions instance.

Declaration
public static AttributeValue Serialize(object value)
Parameters
Type Name Description
System.Object value

The object to serialize.

Returns
Type Description
Amazon.DynamoDBv2.Model.AttributeValue

A DynamoDB attribute value or null when the object state cannot be represented in DynamoDB.

Serialize(Object, DynamoSerializerOptions)

The Serialize(Object, DynamoSerializerOptions) method serializes an object to a DynamoDB attribute value.

Declaration
public static AttributeValue Serialize(object value, DynamoSerializerOptions options)
Parameters
Type Name Description
System.Object value

The object to serialize.

DynamoSerializerOptions options

The serialization options to use.

Returns
Type Description
Amazon.DynamoDBv2.Model.AttributeValue

A DynamoDB attribute value or null when the object state cannot be represented in DynamoDB.

See Also

DynamoDB Data Types
In This Article
Back to top Generated by DocFX