From 174ef1b40f99e30669646ff660848338e1997f32 Mon Sep 17 00:00:00 2001 From: Peter Obel Date: Mon, 24 Oct 2022 23:02:05 +0200 Subject: [PATCH 1/2] do not replicate data --- .../Serialization/TableEntityDynamic.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs b/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs index 503dce5..9d5db3c 100644 --- a/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs +++ b/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs @@ -62,6 +62,12 @@ internal static class TableEntityDynamic // visit all properties foreach (PropertyInfo property in objectProperties) { + if (property.Name == entityMapper.PartitionKeyFormat) + property.SetValue(model, entity.PartitionKey); + + if (property.Name == entityMapper.RowKeyFormat) + property.SetValue(model, entity.RowKey); + if (ShouldSkipProperty(property)) continue; From 1689cbb5e1c2329af19a817505107c72ac3a720f Mon Sep 17 00:00:00 2001 From: Peter Obel Date: Wed, 26 Oct 2022 09:02:03 +0200 Subject: [PATCH 2/2] bug fix when properties only have getters --- .../Serialization/TableEntityDynamic.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs b/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs index 9d5db3c..64459e6 100644 --- a/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs +++ b/CoreHelpers.WindowsAzure.Storage.Table/Serialization/TableEntityDynamic.cs @@ -56,16 +56,17 @@ internal static class TableEntityDynamic // create the target model var model = new T(); + // get all properties from model IEnumerable objectProperties = model.GetType().GetTypeInfo().GetProperties(); // visit all properties foreach (PropertyInfo property in objectProperties) { - if (property.Name == entityMapper.PartitionKeyFormat) + if (property.Name == entityMapper.PartitionKeyFormat && property.SetMethod != null) property.SetValue(model, entity.PartitionKey); - if (property.Name == entityMapper.RowKeyFormat) + if (property.Name == entityMapper.RowKeyFormat && property.SetMethod != null) property.SetValue(model, entity.RowKey); if (ShouldSkipProperty(property))