Non-Derived POCOs and Azure Storage

Is it possible to have an unused POCO to store Azure tables?

In other words, a POCO that is not obtained from TableEntityor implements ITableEntity?

It seems that a step back should have a model that depends on the interface or base class, since this leads to leakage of links up in the chain - I cannot configure the model at a different level without having to know about Azure Storage for the interface or base class!

+5
source share
3 answers

Take a look at DynamicTableEntity(ctrl + f). It can be used to query and insert objects.

, - , POCO DynamicTableEntity - , , POCO ( +, , - Partition/RowKey).

, - Azure, , , Row Key. DynamicTableEntity " " , , , . .

+7

, Nuget: https://www.nuget.org/packages/ObjectFlattenerRecomposer/

Azure Storage SDK: https://github.com/Azure/azure-storage-net/pull/337/files

:

EntityProperty . , API Azure , SDK Azure Storage Client.

2.0 IEnumerable "", "", "" " ".

: https://doguarslan.wordpress.com/2016/02/03/writing-complex-objects-to-azure-table-storage/

: // EntityProperty

flattenedProperties = ObjectFlattenerRecomposer.Flatten(complexObject);

// DynamicTableEntity PK RK DynamicTableEntity dynamicTableEntity = DynamicTableEntity (partitionKey, rowKey);

dynamicTableEntity.Properties = flattenedProperties;

// DynamicicTableEntity Azure Table Storage SDK

// AzureTableStorage DynamicTableEntity, PK RK DynamicTableEntity = [ Azure ];

// DynamicTableEntity . , complexObject Order.

= ObjectFlattenerRecomposer.ConvertBack(entity.Properties);

0

-, TableEntity ITableEntity, DataServiceKey , :

[DataServiceKey("PartitionKey", "RowKey")]
public class MyEntity
{
    public string PartitionKey {get; set;}
    public string RowKey {get; set;}
    public DateTime Timestamp {get; set;}
    //other properties
}

However, this will not solve your problem, not wanting to leak the Azure implementation into your model class. In this case, I think you might need to use a shell implementation, such as LOKAD Fat Entities . Lokad will handle the serialization / deserialization of your model object into a shell, which in turn is stored in a table storage. However, one drawback in Lokad is that your objects become opaque in the warehouse and you cannot view them using Azure Storage Explorer .

-1
source

All Articles