Skip to content

Commit

Permalink
Avoid duplicating values in JSON for deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed May 2, 2022
1 parent 1168f83 commit 77908aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/TableStorage/TableRepository`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ T ToEntity(TableEntity entity)
// perform its advanced ctor and conversion detection as usual.
writer.WriteStartObject();

if (partitionKeyProperty != null)
if (partitionKeyProperty != null && !entity.ContainsKey(partitionKeyProperty))
writer.WriteString(partitionKeyProperty, entity.PartitionKey);

if (rowKeyProperty != null)
if (rowKeyProperty != null && !entity.ContainsKey(rowKeyProperty))
writer.WriteString(rowKeyProperty, entity.RowKey);

if (entity.Timestamp != null)
if (entity.Timestamp != null && !entity.ContainsKey(nameof(ITableEntity.Timestamp)))
writer.WriteString(nameof(ITableEntity.Timestamp), entity.Timestamp.Value.ToString("O"));

foreach (var property in entity)
Expand Down

0 comments on commit 77908aa

Please sign in to comment.