Azure TableEntity EntityResolver to Call and re-use base resolving functionality

513 Views Asked by At

I'm creating a custom EntityResolve, so that when I retrieve my azure table records, I will set a bunch of properties on the Business Object (TableEntity object) that are designed only to be used in my app and not persisted back to the Azure table. The properties on the Azure table are decorated with [IgnoreProperty]

public delegate T EntityResolver<T>(string partitionKey, string rowKey, DateTimeOffset timestamp, IDictionary<string, EntityProperty> properties, string etag);

So, I'm creating the EntityResolver, and I will pass the delegate as a parameter in the ExecuteQuerySegmentedAsync method that will do the custom binding to the Table Entity.

However, I don't want to write code to custom resolve every single property to the TableEntity. I want to use all the default resolving functionality, but then add some additional code and business logic to set the other properties used for business logic.

In the resolver, is there anyway I can tap into the default or a kind of base resoling functionality, so that I do not have to re-write all that logic to do the same thing just because I want to add a few more pieces of code and logic to some new properties?

1

There are 1 best solutions below

4
On BEST ANSWER

EntityResolver is used to customize client-side projection, where the code should all be customized. I haven't found any way provided for this method to get properties resolved automatically.

The resolving functionality can be achieved when we use query methods without resolver. For example: table.ExecuteQuerySegmented(query, continuationToken);

You can add properties to each entity after you get the query result. Like this:

var entities = new List<CustomEntity>();
foreach (CustomEntity c in table.ExecuteQuerySegmented(query, continuationToken))
{
    c.Data = 100;
    ......
    entities.Add(c);
}