1
votes

I building an application based on Azure and I would like to get the columns specification of the entity saved into a table storage before show them.

How can I do that?

1
You mean you want to get the data type of the attributes in an entity? What language are you using?Gaurav Mantri
yes I meant that. I using C#Salvatore Di Fazio

1 Answers

2
votes

Try this code:

    static void GetAttributeTypes()
    {
        storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
        var table = storageAccount.CreateCloudTableClient().GetTableReference("WADLogsTable");
        var query = new TableQuery().Take(1);
        var result = table.ExecuteQuery(query).ToList();
        if (result != null && result.Count > 0)
        {
            var dynamicTableEntity = result[0];
            foreach (var property in dynamicTableEntity.Properties)
            {
                Console.WriteLine(property.Key + " = " + property.Value.PropertyType);
            }
        }
    }

Assuming all entities in a table have same attributes, what I have done is fetched just one entity from the table and looped over its properties. I have used Storage Client library 2.0.6.1.