VKinfotek Inc.
  • Us
    About Us
    Contact Us
  • FAQs
  • Ready Software
    Ready ERP ASP Core Software for Azure Cloud
    Ready Web ERP Software
    Ready ASP.Net Azure Software
    Ready C# SQL Server Accounting Software
    Ready ASP.Net MVC and EF Software
Earn $100/hour in USA! Click Here

Q80: How do I retrieve a single entity from Table Storage using TableOperation?

In this question, we will see how to retrieve the data from the Table storage. The below example code demonstrates how to construct a simple query to retrieve a single, specific entity. The following code uses a TableOperation to specify an item with PartitionKey 'RawMaterial' and RowKey 'R001'. This method returns just one entity, rather than a collection, and the returned value in TableResult.Result is an ItemEntity. Specifying both PartitionKey and RowKey in a query, is the fastest way to retrieve a single entity from the Table.

  
try
{
// Retrieve the storage account from the connection string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudTableClient client = account.CreateCloudTableClient();
CloudTable table = client.GetTableReference("items");
TableOperation retrieveOperation= TableOperation.Retrieve<ItemEntity>("RawMaterial","R001");
TableResult query = table.Execute(retrieveOperation);
if (query.Result != null)
{
	Console.WriteLine("Item: {0}", ((ItemEntity)query.Result).Name);
}


When we execute this code, the entity is retrieved and the Item name is displayed. There are many ways of querying the data in the table and we will discuss about them in the coming questions. In the earlier versions of the .Net Storage library 2.x, LINQ was used to query tables. Storage Client library 2.0 utilizes the new Microsoft.Data.OData library, and this offers greater performance. However, LINQ can still be used to query table storage and the classes are in Microsoft.WindowsAzure.Storage.Table.DataServices library.

In Storage Client library 2.0, a lightweight query class 'TableQuery' is included. Using this class we can construct complex queries, but the syntax is not as simple as in LINQ.
  • Prev Question
  • Next Question

See More Questions and Answers on - Azure Table Storage (cont..)

  • How to access the Azure table storage from a .NET application?
  • What is an Azure storage connection string?
  • How to configure Azure connection strings?
  • How to configure Azure connection strings for connecting to the storage emulator?
  • How to create a table in Azure storage?
  • How to create a table using a simple c# console application?
  • How to insert entities into the Azure table?
  • How do I query azure table storage using TableQuery class?
  • How to update records in a table storage?

Back to Master List of 100+ Questions and Answers

People also viewed: cover image of book develop erp software using asp core and deploy to Azure Create your own ERP Software using ASP Core>>
cover image of azure cloud book Create your own Azure SOM Software>>
cover image of asp.net book Create your own ERP Software using ASP .Net and SQL>>
cover image of foundation database programming book Create your own Accounting Software using C# >>
cover image of entity framework book Create your own SOM using Entity Framework MVC >>

  • SITEMAP
  • Terms of use
  • Testimonials

Back to top

Copyright © 2018 - All Rights Reserved - VKInfotek.com