Querying Azure Table Storage Dynamically With TechSmith Hyde
Lately I’ve been working on TechSmith Hyde a fair bit at work. One interesting workflow that Hyde allows is interacting with Table Storage via dynamics. For example, here is the code to query one row in a table.
All Table Storage operations (Add/Insert/Update/Upsert/Delete) are supported with dynamics as well.
Using this pattern, multiple types of records can be stored in the same partition without needing to declare models for each record type. This is good for two reasons, first records stored in the same partition can be accessed with Entity Group Transactions. This is useful if you want to modify several different records at the same time. The second reason is flexibility. For example, with a tool like LINQPad you can query Table Storage without knowing what properties a row might contain.
Finally, this opens up the possibility to query those different record types at runtime and handle them separately based on what properties are definied.
This code will query all records we have for the
"Dog" partition and process them, handling both the animal type and animal instance records. This could be even be expanded to handle multiple different types of records with the same query. The benefit is that it only takes 1 query to bring back all records. I wouldn’t recommend dynamic querying for every situation, but it can be a powerful tool in your Azure toolbox.