locked
How do I read the value of a property from Azure table? RRS feed

  • Question

  • User-296654088 posted

    Hi,

    This is my first attempt to read some data from an Azure table in my MVC app. I added only one property to my Azure table called UserId which is of Integer type.

    Looks like my code retrieves the record with the proper value. I just haven't been able to grab the value. Here's my code:

    TableResult retrievedResult = table.Execute(retrieveOperation);

    How do I grab the property value from here and put it into an integer variable?

    Tuesday, April 8, 2014 10:10 PM

All replies

  • User1510331810 posted

    Hi Sam,

    You need to read this article

    http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-table-storage-20/

    It's provide an example "Create Table, Add, Update, Delete an Entity.

    Hope it going to solved your issue

    Sunday, April 13, 2014 3:51 AM
  • User-505443061 posted

    Hi,

    property "Result" of retrievedResult should contains the value you are looking for.

    For example:

    TableOperation retrieveOperation = TableOperation.Retrieve<Person>("1","1");
    
    // Execute the retrieve operation.
    
    TableResult retrievedResult = table.Execute(retrieveOperation);
    

     

    retrievedResult contains object of type Person.

    I.e. Person is defined in this way:

        public class Person: TableEntity
        {
            public Person(string partitionKey, string rowKey, string firstName, string lastName, double salary)
                :base(partitionKey, rowKey)
            {
                FirstName = firstName;
                LastName = lastName;
                Salary = salary;
            }
    
            public Person():base() { }
    
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public double Salary { get; set; }
    
        }
    

    Bye

    Monday, April 14, 2014 5:18 PM