using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Ria; using System.Web.Ria.Data; using System.Web.DomainServices; using Microsoft.Azure.DomainServices; using Hanray.Azurelight.Model; namespace Hanray.Azurelight.Service { [EnableClientAccess()] public class SurveyService : AzureDomainService<SurveyDataContext> { private SurveyDataContext _dataContext; public SurveyService() { } #region Azure Specifics protected override string GetPartitionKey() { return "AzurelightSureveyTable"; } protected override SurveyDataContext CreateDataContext() { if (_dataContext != null) { return _dataContext; } _dataContext = base.CreateDataContext(); _dataContext.RetryCount = 2; return _dataContext; } #endregion #region CRUD - Query, Create, Insert and Update //[Query] public IQueryable<Survey> GetSurveys() { return DataContext.Surveys; } //[ServiceOperation] public void AddSurvey(Survey survey) { survey.RowKey = Guid.NewGuid().ToString(); survey.Timestamp = DateTime.UtcNow; DataContext.Surveys.InsertOnSubmit(survey); } //[Update] public void UpdateSurvey(Survey currentSurvey) { DataContext.Surveys.Attach(currentSurvey, currentSurvey, GetETag(currentSurvey)); } #endregion } }
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.
This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)