title: Implementing Azure Table's ITableEntity interface to support nested objects and custom property types
body: <p>Azure Table Storage supports only basic data types like (int, string, Guid, DateTime) etc. This makes it hard to store objects which themselves contain objects inside them i.e. nested objects. It is also not supported to directly store List&lt;> and other such collection data types.</p>
  
  <p>For this, I created a CustomEntity class which inherits from ITableEntity and implemented the ReadEntity and WriteEntity methods using the newly introduced <code>TableEntity.Flatten(...)</code> and <code>TableEntity.ConvertBack&lt;TResult&gt;(...)</code> methods. I am for now only focusing on storing nested objects.</p>
  
  <pre><code>public class CustomEntity : ITableEntity
  {
      // Partition Key, Row Key, Timestamp and ETag here
  
      public void ReadEntity(IDictionary&lt;string, EntityProperty&gt; properties, OperationContext operationContext)
      {
          CustomEntity customEntity = TableEntity.ConvertBack&lt;CustomEntity&gt;(properties, operationContext);
          // Do the memberwise clone for this object from the returned CustomEntity object
          CloneThisObject(this, customEntity);
      }
  
      public IDictionary&lt;string, EntityProperty&gt; WriteEntity(OperationContext operationContext)
      {
          IDictionary&lt;string, EntityProperty&gt; flattenedProperties = TableEntity.Flatten(this, operationContext);
          flattenedProperties.Remove("PartitionKey");
          flattenedProperties.Remove("RowKey");
          flattenedProperties.Remove("Timestamp");
          flattenedProperties.Remove("ETag");
          return flattenedProperties;
      }
  }
  </code></pre>
  
  <p>I used the above code in my model and was able to successfully insert a nested object in the Azure tables. The issue comes when I want to retrieve the same object. The code gets stuck in an infinite loop at the <code>table.Execute(TableOperation.Retrieve(partitionKey, rowKey))</code> command. </p>
  
  <p>Also, while the WriteEntity code was hit during insert operation of the CustomEntity object, the ReadEntity code isn't hit while retrieving the entity. What am I missing here? Any help would be greatly appreciated.</p>