How to use EntityResolver with Azure Storage? How to use EntityResolver with Azure Storage? azure azure

How to use EntityResolver with Azure Storage?


Here is a nice article describing the Table Storage in deep. It also includes couple of samples for EntityResolver.

Ideal would be to have one Generic Resolver, that produces the desired result. Then you can include it in your call. I will just quote here one example from the provided article:

EntityResolver<ShapeEntity> shapeResolver = (pk, rk, ts, props, etag) =>{    ShapeEntity resolvedEntity = null;    string shapeType = props["ShapeType"].StringValue;    if (shapeType == "Rectangle") { resolvedEntity = new RectangleEntity(); }    else if (shapeType == "Ellipse") { resolvedEntity = new EllipseEntity(); }    else if (shapeType == "Line") { resolvedEntity = new LineEntity(); }        // Potentially throw here if an unknown shape is detected     resolvedEntity.PartitionKey = pk;    resolvedEntity.RowKey = rk;    resolvedEntity.Timestamp = ts;    resolvedEntity.ETag = etag;    resolvedEntity.ReadEntity(props, null);    return resolvedEntity;};    currentSegment = await drawingTable.ExecuteQuerySegmentedAsync(drawingQuery, shapeResolver, currentSegment != null ? currentSegment.ContinuationToken : null);

Read the full article to better understand the deal with resolvers.