Database Reference
In-Depth Information
the Add New Item dialog, select the Code category and select the Class template.
Change the name of the class to StudentClubDataSource.cs and click Add . After the
StudentClubDataSource.cs ile is opened, enter the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace StudentClub_Info
{
public class StudentClubDataSource
{
//Declaring the storageAccount object to store account info.
private static CloudStorageAccount storageAccount;
//Declaring the Context object to expose tables to an
//application.
private StudentClubContext context;
//The constructor is used to initializes storage account info
//and creates a table with the defined schema.
static StudentClubDataSource()
{
//Instantiate the storageAccount object with data
//connection string
storageAccount =
CloudStorageAccount.FromConfigurationSetting("DataConnectionSt
ring");
//Creating a table with the storageAccount and Context
//objects
CloudTableClient.CreateTablesFromModel(
typeof(StudentClubContext),
storageAccount.TableEndpoint.AbsoluteUri,
storageAccount.Credentials);
}
//initializing the data source.
public StudentClubDataSource()
{
//Initialize context using account info.
this.context =
new StudentClubContext(storageAccount.TableEndpoint.
AbsoluteUri,
storageAccount.Credentials);
//Initialize retry update policy.
this.context.RetryPolicy = RetryPolicies.Retry(3,
 
Search WWH ::




Custom Search