- thumbnails_e1_code.zip
- Thumbnails_E1
- buildme.cmd
- packme.cmd
- readme.txt
- runme.cmd
- Thumbnails.proj
- Thumbnails_E1.sln
- Thumbnails_E1
- bin
- Debug
- Thumbnais_E1.csx
- roles
- Thumbnails_E1_WebRole
- approot
- bin
- Images
- base
- x86
- diagnostics
- x86
- storage
- simulation
- x86
- Thumbnails_E1_WorkerRole
- approot
- base
- x86
- diagnostics
- x86
- storage
- simulation
- x86
- ServiceConfiguration.cscfg
- ServiceDefinition.csdef
- Thumbnais_E1.ccproj
- Thumbnais_E1.ccproj.user
- Thumbnails_E1_WebRole
- Thumbnails_E1_WorkerRole
- Thumbnails_E1.zip
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.Data.Services.Client;
namespace Thumbnails_WebRole
{
public class PhotoTableDataSource
{
private PhotoTableDataServiceContext _ServiceContext = null;
public PhotoTableDataSource()
{
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
_ServiceContext = new PhotoTableDataServiceContext(storageAccount.TableEndpoint.ToString(),
storageAccount.Credentials);
// Create the tables
// In this case, just a single table.
storageAccount.CreateCloudTableClient().CreateTableIfNotExist
(PhotoTableDataServiceContext.PhotoTableName);
}
public IEnumerable<PhotoTableDataModel> Select()
{
var results = from c in _ServiceContext.PhotoTableData
select c;
var query = results.AsTableServiceQuery<PhotoTableDataModel>();
var queryResults = query.Execute();
return queryResults;
}
public void Delete(PhotoTableDataModel itemToDelete)
{
//Commented out for now, may be needed
// _ServiceContext.AttachTo(PhotoTableDataServiceContext.PhotoTableName, itemToDelete, "*");
_ServiceContext.DeleteObject(itemToDelete);
_ServiceContext.SaveChanges();
}
public void Insert(PhotoTableDataModel newItem)
{
_ServiceContext.AddObject(PhotoTableDataServiceContext.PhotoTableName, newItem);
_ServiceContext.SaveChanges();
}
public void Update(PhotoTableDataModel updateItem)
{
//Commented out for now, may be needed
//_ServiceContext.AttachTo(PhotoTableDataServiceContext.PhotoTableName, updateItem);
_ServiceContext.UpdateObject(updateItem);
_ServiceContext.SaveChanges();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Vijay Kumar: Architect, Programmer with expertise and interest in Azure, .net, Silverlight, C#, WCF, MVC, databases and mobile development. Concentrating on Windows Phone 7 and Windows Azure development. Lived in California for many years and done many exciting projects in dotnet and Windows platforms. Moved to Raleigh (RTP), North Carolina recently and available for consulting. Blog http://Silverazure.blogspot.com.