Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

Doing CRUDy stuff with the Table service (part 1) - Creating a context class

3/12/2011 10:39:53 PM
- Windows 10 Product Activation Keys Free 2019 (All Versions)
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
In this section, you’ll build a new product-management web page to manage the Hawaiian shirt product list stored in the Table service. Through this web page, you’ll be able to create, read, update, and delete (also known as CRUD) data in the table. Figure 1 shows what the web page will look like.
Figure 1. Product-management web page


The product-management web page shown in figure 1 will allow us to do several things:

  • Add new shirts

  • List all shirts

  • Edit existing shirts

  • Delete shirts

You’ve already set up the entity and registered the entity table in the development storage. It’s time to develop the product-management web page shown in figure 1. The first step is to set up a context class for your entity.

1. Creating a context class

In order to work with entities in any way (query, add, insert, delete) using ADO.NET Data Services, you first need to set up a context object.

The context class is really a bridge between an entity and ADO.NET Data Services. It will define the endpoint of the storage account, the name of the table that we’ll query, and the entity that will be returned. The following listing shows the context class for the Products table.

Listing 1. Product context class

Listing 1 shows the context object for the Hawaiian shirt Product entity. As you can see, most of the complexity of the context class is abstracted away in the classes that you inherit from. The TableServiceContext class inherits from the standard ADO.NET Data Services context class, DataServicesContext. The TableServiceContext class provides some additional functionality beyond what is provided out of the box with ADO.NET Data Services, including retry policies.

In listing 1, the storage account details and credentials are automatically populated from the service configuration. This allows you to simplify your calling classes—you don’t need to get the endpoint and credentials every time you wish to use the context class.

Finally, the Product property is what you’ll use to perform LINQ queries on the Products table.

Tip

Code generation is outside the scope of this book, but if you’re generating a large number of tables and entities, you may wish to consider using a code generation tool such as T4 to autogenerate code where possible. Typical areas to consider generating code automatically would include table context classes and table-creation scripts.


Let’s look at how you can start using this.

Other -----------------
- Developing with the Table service
- Partitioning data across lots of servers : Partitioning the storage account & Partitioning tables
- Modifying an entity to work with the Table service
- How we’d normally represent entities outside of Azure
- A brief overview of the Table service
- BLOBs : Setting shared access permissions
- Enterprise Service Bus with BizTalk Server and Windows Azure : Distributed and Scalable ESB Architecture
- Enterprise Service Bus with BizTalk Server and Windows Azure : The ESB Toolkit
- Enterprise Service Bus with BizTalk Server and Windows Azure : Integration with BizTalk
- Copying BLOBs - Copying files via the StorageClient library
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server