Опубликован: 30.05.2011 | Доступ: свободный | Студентов: 2366 / 213 | Оценка: 4.12 / 4.41 | Длительность: 12:00:00
Самостоятельная работа 5:

Работа с Windows Azure Table

< Самостоятельная работа 4 || Самостоятельная работа 5: 1234567 || Лекция 13 >

Приложение Б. Класс Contact.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebRole1
{
    class Contact : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
    {
        public String FirstName { get; set; }
        public String LastName { get; set; }
        public String TelNumber { get; set; }
        public String Email { get; set; }
    }
}

Приложение В. Класс ContactContext.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.Data.Services.Client;

namespace WebRole1
{
    class ContactContext : TableServiceContext
    {

        public IQueryable<Contact> ContactData
        {
            get
            {
                return this.CreateQuery<Contact>("Contacts");

            }
        }

        public ContactContext(Uri baseAddress, StorageCredentials credentials) : base(baseAddress.AbsoluteUri, credentials) { }

        public void Add(Contact cnt)
        {
            this.AddObject("Contacts", cnt);
            this.SaveChanges();
        }

        public void Delete(Contact cnt)
        {
            this.DeleteObject(cnt);
            this.SaveChanges();
        }

        public void Update(Contact cnt)
        {
            this.UpdateObject(cnt);
            this.SaveChanges();
        }
    }
}

Приложение Г. Global.asax.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.Data.Services.Client;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace WebRole1
{
    public class Global : System.Web.HttpApplication
    {

        void Application_Start(object sender, EventArgs e)
        {

            CloudStorageAccount.SetConfigurationSettingPublisher(
                (configName, configSettingPublisher) =>
                {
                    var connectionString =
                        RoleEnvironment.GetConfigurationSettingValue(configName);
                    configSettingPublisher(connectionString);
                }
            ); 

            var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            CloudTableClient _tc = null;
            _tc = account.CreateCloudTableClient();
            _tc.CreateTableIfNotExist("Contacts");


        }

        void Application_End(object sender, EventArgs e)
        {
  
        }

        void Application_Error(object sender, EventArgs e)
        {

        }

        void Session_Start(object sender, EventArgs e)
        {

        }

        void Session_End(object sender, EventArgs e)
        {

        }

    }
}
< Самостоятельная работа 4 || Самостоятельная работа 5: 1234567 || Лекция 13 >
Роза Мальцева
Роза Мальцева
Игнат Гринько
Игнат Гринько

Примерно месяц назад получил на сайте код Дримспарк, сегодня вводил его на сайте Дримспарк, пишет: Недействительный код проверки. Проверьте правильность введенного кода. Код вводил методом: скопировать-вставить.