Skip to content

Commit

Permalink
Added support for null/empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodafonseca committed Jul 10, 2019
1 parent da54812 commit b8441a0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Dynamo.ORM/Constants/AttributeValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,16 @@ internal class AttributeValueConverter
return attributeValue;
}
},
{ typeof(string), (object @object) => new AttributeValue($"{@object}") },
{ typeof(string), (object @object) =>
{
var attributeValue = new AttributeValue();
if (!string.IsNullOrWhiteSpace($"{@object}"))
attributeValue.S = $"{@object}";
else
attributeValue.NULL = true;
return attributeValue;
}
},
{ typeof(ushort), (object @object) => new AttributeValue{ N = $"{@object}" } },
{ typeof(ushort?), (object @object) =>
{
Expand Down Expand Up @@ -164,7 +173,7 @@ internal class AttributeValueConverter
return attributeValue;
}
},
{ typeof(object), (object @object) =>
{ typeof(object), (object @object) =>
{
var attributeValue = new AttributeValue();
if (@object == null)
Expand Down Expand Up @@ -285,7 +294,13 @@ internal class AttributeValueConverter
return null;
}
},
{ typeof(string), (AttributeValue attributeValue) => attributeValue.S },
{ typeof(string), (AttributeValue attributeValue) =>
{
if (!attributeValue.NULL)
return attributeValue.S;
return null;
}
},
{ typeof(ushort), (AttributeValue attributeValue) => ushort.Parse(attributeValue.N) },
{ typeof(ushort?), (AttributeValue attributeValue) =>
{
Expand Down

0 comments on commit b8441a0

Please sign in to comment.