Azure – Rich Client(s) meets Azure Table Data. Smart Grid Sample – Step 06

This is Step 06. Many more steps to follow.

At the end, you will have Silverlight talking to Azure Tables

 

The reference application will be based on Smart Grid concepts. For the first round of development we will add some addresses of homes that have smart meters. We simply track the number of smart meters per house. Future versions will use Virtual Earth, and more advanced graphics with Silverlight.

The application will contain addresses and smart meter information.

Our future tasks will include.

Stop the application. "Debug, Stop Debugging" from the Visual Studio menu.

Select "Web Form" and provide the name ViewHomes.aspx

We will paste in our new grid.

 

Paste in the starter grid code markup.

 

Grid code below:

<asp:GridView ID="HomeGridView" runat="server">

</asp:GridView>

<asp:Button id="AddHomeButton" runat="server" text="Add Home" />

Our ViewHomes.asp starter grid.

The Value of StorageClient

StorageClient is installed with the Azure SDK. It provides a lot of value and saves time.

You can read more about StorageClient on MSDN.

In summary, StorageClient simplifies data calls from the cloud.

Add the existing StorageClient project. It can be found:

C:\Program Files\Windows Azure SDK\v1.0\StorageClient

StorageClient is now part of the project:

You will add storage client to the solution.

We need to inherit from TableStorageEntity

Tables store data as collections of entities.

What is an entity?

Entities are similar to rows.

An entity has a primary key and a set of properties.

A property is a name, typed-value pair, similar to a column.

A table may contain any number of entities

Key Point – No Schemas – It is up to you

The Table service does not enforce any schema for tables, so two entities in the same table may have different sets of properties.

Developers may choose to enforce a schema on the client side.

Add A New Class (Home.cs)

The Home.cs class it our main data object. It will mirror a table in the cloud. Later, we create an Azure table and a SQL Server table based on Home.cs.

 

Make sure you have your reference set

Home Class

//using Microsoft.Samples.ServiceHosting.StorageClient;

public class Home : TableStorageEntity

{

public Home()

{

this.PartitionKey = "Homes";

}

public Home(int homeID,

string homeownerName,

string city,

string state,

string zip,

int numberofmeters)

: base("Homes", homeID.ToString())

{

this.homeID = homeID;

this.HomeownerName = homeownerName;

this.City = city;

this.State = state;

this.NumberOfMeters = numberofmeters;

}

private int homeID;

 

public string HomeownerName

{

get; set;

}

  

public string Address

{

get;

set;

}

  

public string City

{

get;

set;

}

  

public string State

{

get;

set;

}

  

public string Zip

{

get;

set;

}

  

public int NumberOfMeters

{

get;

set;

}

public string HomeAddressMapUrlFileUpload

{

get;

set;

}

  

public int HomeID

{

get

{

return homeID;

}

set

{

this.RowKey = value.ToString();

homeID = value;

}

}

}