Thursday, November 20, 2008

Azure Storage Services Test Harness: Table Services 4 – Programming the Table Services API

Update 1/31/2009: Code is now available for download.

This is the fourth of a series of articles about a ASP.NET 3.5 C# test harness for Azure Storage Services that is will be available for download from my “Retire Your Data Center” cover story for Visual Studio Magazine’s February 2009 issue (click the Get Code Download link) in the near future.

The Microsoft.Samples.ServiceHosting.StorageClient namespace consists of helper classes contained in nine *.cs class files of which two—TableStorage.cs and StorageAccountInfo.cs contain classes used by the classes that define the central EntityNameDataModel and EntityNameDataServiceContext classes where EntityName = Customer for this example.

Preceding episodes of this series are:

The following two sections contain code that defines the CustomerDataModel class and the CustomerServiceContext class.

The EntityNameDataModel Class

The LINQ In-Memory Object Generator (LIMOG) v2 program (see Azure Storage Services Test Harness: Table Services 5 – Generating the Collection Initializer with LIMOG v2) autogenerates the EntityNameDataModel class from the selected data table. This class derives from the TableStorageEntity abstract class in TableStorage.cs:

The Customers table’s properties are all of the string type; LIMOG v2 generates similar classes for other tables with more divergent data types as well as classes for SQL Data Services (SDS) containers.

Following is a partial screen capture of LIMOG v2’s collection initializer for the CustomerTable with the RowKey equal to the CustomerID value:

The EntityNameDataService Class

The EntityNameDataService class inherits the TableStorageDataServiceContext class from TableService.cs. Its constructor requires an argument of the StorageAccountInfo class, which is defined in the StorageAccountInfo.cs file.

The later “TableStorage.cs Classes in the StorageClient Assembly” and The “StorageAccountInfo Class” sections have TableServices and StorageAccountInfo class diagram screen captures.

An customerData ObjectDataSource control binds to the CustomerDataSource class and its Select(), Insert(), and Delete() methods to support the Default.aspx Web page’s bound DataView and FormView controls:

The GridView displays only a few columns to enable exposing the PartitionKey and RowKey values without horizontal scrolling:

TableStorage.cs Classes in the StorageClient Assembly

The StorageClient assembly is a set of .NET wrapper classes for REST operations of the Table Storage, Blog Storage and Queue APIs. The assembly lets developers use the ADO.NET Data Services’ .NET Client library (System.Data.Services.Client)

The StorageInfo Class

The next episode in this series is Azure Storage Services Test Harness: Table Services 5 – Generating the Collection Initializer with LIMOG v2.

1 comments:

Andy said...

The CustomerDataSource class, for direct use of a GridView looks very clean and simple for RAD development.

I really do see WebForms and the Cloud services becoming Microsoft's main play against Salesforce Force and Oracle APEX platforms. And developing in Visual Studio it should really trump these other platforms.

Thanks for the very detailed code post.