See the version list below for details.
dotnet add package ObjectFlattenerRecomposer --version 2.0.0
NuGet\Install-Package ObjectFlattenerRecomposer -Version 2.0.0
<PackageReference Include="ObjectFlattenerRecomposer" Version="2.0.0" />
paket add ObjectFlattenerRecomposer --version 2.0.0
#r "nuget: ObjectFlattenerRecomposer, 2.0.0"
// Install ObjectFlattenerRecomposer as a Cake Addin #addin nuget:?package=ObjectFlattenerRecomposer&version=2.0.0 // Install ObjectFlattenerRecomposer as a Cake Tool #tool nuget:?package=ObjectFlattenerRecomposer&version=2.0.0
Integrated into Azure Storage SDK v18.104.22.168 https://msdn.microsoft.com/en-us/library/mt775435.aspx https://msdn.microsoft.com/en-us/library/mt775432.aspx
Provides functionality to flatten complex objects into EntityProperty dictionary and functionality to recompose original complex object from the flattened property dictionary. One usage is that the API allows writing any complex object with nested properties into Azure Table Storage in flattened form wih individual columns. The API also allows you to save Enum, TimeSpan, DateTimeOffset, Nullable property types to Azure Table Storage.
IEnumerable Properties: Lists, Arrays, Dictionaries,...
With V2.0.0 of the api, I have implemented support for any property type that implements IEnumerable interface. That is a big change and it covers as we know most commonly known collection types like List, Array, Dictionary, their generic versions and other interfaces that inherit from IEnumerable like ICollection, IReadOnlyCollection etc. With this change these properties would be automatically converted to json strings when flattened by the api, when reading the entity back from azure, the api will recompose the original property with the correct type and correct values all transparently.
What is the Minimum Requirement to flatten my complex object with ObjectFlattenerRecomposer API?
The minimum requirement is that your properties need to have both Getter and Setter. The Getter and Setter do not need to be public, they can be protected or private. If there is a property that you cannot/do not want to add a Setter even a private one, then you can exclude that property from being flattened by putting the [IgnorePropertyAttribute] to it as explained below. How do I exclude some properties from being flattened? There may be some use cases where you may want to exclude certain properties from being flattened ie. you have some Get only properties and you do not want to add even a private Setter for those or you do not want to write certain properties eventually to table storage in that case all you need to do is to add [IgnorePropertyAttribute] attribute to the top of the properties you want to exclude.
Flattening Composite Objects and Recursive Referenced objects:
A composite object is an object that has a property of its own type. Object Flattener Recomposer API can flatten and recompose composite objects of any depth as long as the properties do not have recursive references ie. referring back to the root or a parent property. In case of recursive referenced objects, v1.1.3 and above versions of the Object Flattener Recomposer API detects the recursive references anywhere along the object graph and exits from flattening operation, returning a null result. This avoids the flattener from going into an infinite loop traversing inside the recursive path in the object graph.
using ObjectFlattenerRecomposer; //Flatten object and convert it to EntityProperty Dictionary Dictionary<string, EntityProperty> flattenedProperties = EntityPropertyConverter.Flatten(complexObject); // Create a DynamicTableEntity and set its PK and RK DynamicTableEntity dynamicTableEntity = new DynamicTableEntity(partitionKey, rowKey); dynamicTableEntity.Properties = flattenedProperties; // Write the DynamicTableEntity to Azure Table Storage using client SDK //Read the entity back from AzureTableStorage as DynamicTableEntity using the same PK and RK DynamicTableEntity entity = [Read from Azure using the PK and RK]; //Convert the DynamicTableEntity back to original complex object. Imagine original complexObject was of type Order. Order order = EntityPropertyConverter.ConvertBack<Order>(entity.Properties);
|.NET Framework||net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481|
- WindowsAzure.Storage (>= 4.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ObjectFlattenerRecomposer:
Converts objects to DynamicTableEntities and DynamicTableEntities back to original objects. Handles conversion of complex objects with complex nested properties. Usage: // Convert Order object to DynamicTableEntity DynamicTableEntity dynamicTableEntity = DynamicTableEntityConverter.ConvertToDynamicTableEntity(order, "pk", "rk"); // Convert DynamicTableEntity back to Order object Order originalOrder = DynamicTableEntityConverter.ConvertToPOCO<Order>(dynamicTableEntity);
This package is not used by any popular GitHub repositories.
Update to version 2.0
- Added support for all IEnumerable type properties (List, Array, Dictionary, ICollection, IReadOnlyCollection etc.). Automatically converts these properties to json when writing to table storage. Recreates the original IEnumerable property with correct type when reading from the table.
- Added support for byte type property.