AzureストレージテーブルにC#オブジェクトを格納するとき、プライベートセッターでのプロパティは無視されます。設定者を公開せずにこれらのプロパティをテーブルに書き込むことは可能ですか?プライベートセッターでAzureテーブルにPOCOを保存
Json.netはJsonProperty属性によってこの機能を提供します。ストレージテーブルに使用できる属性はありますか?私が見つけることができる唯一のプロパティは、プロパティを無視するために使用されるIgnorePropertyAttributeです。
class TestEntity : TableEntity
{
public TestEntity(string property1, string property2)
{
this.Property1 = property1;
this.Property2 = property2;
}
public string Property1 { get; set; }
public string Property2 { get; private set; }
}
TestEntity testEntity = new TestEntity("Value1", "Value2");
testEntity.PartitionKey = "PartitionKey";
testEntity.RowKey = "RowKey";
TableOperation insertOperation = TableOperation.Insert(testEntity);
table.Execute(insertOperation);
上記の例では、Property1(Value1)のみがテーブルに格納されています。 Property2の値は格納されません。これを保存してセッターをパブリックに変更する唯一の方法です。
それは素晴らしいだろう。 – mjwills
この問題を示すサンプルコードを追加しました。 – mtcup
[Azureテーブルストレージに任意のキー値のペアを格納するにはどうすればいいですか?](https://stackoverflow.com/questions/14595486/how-can-i-store-arbitrary-key-value-pairs-in-あなたのProperty2をWriteEntity()メソッドとReadEntity()メソッドに追加するには、その答えを参照してください。 –