當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudTable.Execute方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.Storage.Table.CloudTable.Execute方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudTable.Execute方法的具體用法?C# CloudTable.Execute怎麽用?C# CloudTable.Execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.Storage.Table.CloudTable的用法示例。


在下文中一共展示了CloudTable.Execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Init

        public virtual void Init()
        {
            var client = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudTableClient();
            _table = client.GetTableReference("kalixleotablequery");
            _table.CreateIfNotExists();

            _table.Execute(TableOperation.InsertOrReplace(BuildEntity("test1", "test1")));
            _table.Execute(TableOperation.InsertOrReplace(BuildEntity("test1", "test2")));
            _table.Execute(TableOperation.InsertOrReplace(BuildEntity("test2", "test1")));
            _table.Execute(TableOperation.InsertOrReplace(BuildEntity("test2", "test2")));

            _query = new AzureTableQuery<TestEntity>(_table, null);
        }
開發者ID:KalixHealth,項目名稱:Kalix.Leo,代碼行數:13,代碼來源:AzureTableQueryTests.cs

示例2: CopyEntity

 private void CopyEntity(DynamicTableEntity entity, CloudTable destTable)
 {
     ConsoleWrite.Verbose("    Copying {0} / {1}", entity.PartitionKey, entity.RowKey);
     if (_args.IsReal)
     {
         var operation = TableOperation.Insert(entity);
         destTable.Execute(operation);
     }
 }
開發者ID:colinangusmackay,項目名稱:xander-azure-tools,代碼行數:9,代碼來源:CopyCommand.cs

示例3: InsertSession

        private static void InsertSession(CloudTable table)
        {
            //Create some data to store
            var session = CreateSession();

            // Create the TableOperation object that inserts the session entity.
            var insertOperation = TableOperation.Insert(session);

            // Execute the insert operation.
            table.Execute(insertOperation);
        }
開發者ID:XpiritBV,項目名稱:mini-hacks,代碼行數:11,代碼來源:Program.cs

示例4: LookupAsync

        // Used to fetch an existing container entry so we can append it. 
        public static Task<ContainerActiveEntity> LookupAsync(CloudTable table, long timeBucket, string containerName)
        {
            TableOperation retrieveOperation = TableOperation.Retrieve<ContainerActiveEntity>(
                TableScheme.ContainerActivePK,
                RowKeyTimeInterval(timeBucket, containerName));

            // Execute the retrieve operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);

            var x = (ContainerActiveEntity)retrievedResult.Result;
            return Task.FromResult(x);
        }
開發者ID:ConnorMcMahon,項目名稱:azure-webjobs-sdk,代碼行數:13,代碼來源:ContainerActiveEntity.cs

示例5: Search2

        private static void Search2(CloudTable table)
        {
            TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEntity>("Harp", "Ben");

            // Execute the retrieve operation.
            TableResult retrievedResult = table.Execute(retrieveOperation);

            // Print the phone number of the result.
            if (retrievedResult.Result != null)
                Console.WriteLine(((CustomerEntity)retrievedResult.Result).PhoneNumber);
            else
                Console.WriteLine("The phone number could not be retrieved.");
        }
開發者ID:tzkwizard,項目名稱:ELS,代碼行數:13,代碼來源:ChatBackup.cs

示例6: DashboardUpdate

        public DashboardUpdate(CloudTable generalInfoTable, CloudTable pageTable, CloudTable errorTable, CloudTable mappingTable, CloudQueue urlQ)
        {
            this.dashboardTable = generalInfoTable;
            this.pageTable = pageTable;
            this.errorTable = errorTable;
            this.mappingTable = mappingTable;
            this.urlQ = urlQ;

            IEnumerator<Dashboard> results = generalInfoTable.ExecuteQuery(new TableQuery<Dashboard>()).GetEnumerator();
            if (!results.MoveNext())
            {
                generalInfoTable.Execute(TableOperation.InsertOrReplace(new Dashboard(0, 0, 0, new List<string>(), new List<string>())));
            }
        }
開發者ID:kxchiu,項目名稱:INFO344,代碼行數:14,代碼來源:[PA+4]+DashboardUpdate.cs

示例7: Setup

        public void Setup()
        {
            this.storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
              this.tableClient = storageAccount.CreateCloudTableClient();
              this.table1 = tableClient.GetTableReference("table1");
              this.table1.DeleteIfExists();
              this.table1.Create();

              var entityToCreate = new TestEntity()
              {
            ID = "1",
            FirstName = "Cecil",
            LastName = "Cedar"
              };

              entityToCreate.PartitionKey = entityToCreate.LastName;
              entityToCreate.RowKey = entityToCreate.ID;

              var op = TableOperation.Insert(entityToCreate);
              table1.Execute(op);
        }
開發者ID:kzhen,項目名稱:RefUnited-IVR-Platform,代碼行數:21,代碼來源:AzureStorageTests.cs

示例8: Initialize

        public static void Initialize(TestContext context)
        {
            ConnectionStringSettingsCollection settings =
                ConfigurationManager.ConnectionStrings;
            ConnectionStringSettings connectionStringSettings = settings["Azure"];
            var builder = new DbConnectionStringBuilder
                          {
                          	ConnectionString = connectionStringSettings.ConnectionString
                          };
            accountName = (string) builder["AccountName"];
            accountKey = (string) builder["AccountKey"];
            var account = CloudStorageAccount.Parse(connectionStringSettings.ConnectionString);
            CloudTableClient tableClient = account.CreateCloudTableClient();

            // Create Table
            table = tableClient.GetTableReference(TableName);
            var b = table.DeleteIfExists();
            Console.WriteLine(string.Format("deleted table {0}: {1}", TableName, b));
            table.CreateIfNotExists();

            // Insert Entity
            var person = new ContactEntity("Peter", "Ritchie") { Email = "[email protected]", PhoneNumber = "555-0123" };
            table.Execute(TableOperation.Insert(person));
        }
開發者ID:peteraritchie,項目名稱:RestCloudTable,代碼行數:24,代碼來源:RestCloudTableExistingDataTests.cs

示例9: TableUpdateSasTestSync

        public void TableUpdateSasTestSync()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("T" + Guid.NewGuid().ToString("N"));

            try
            {
                table.Create();

                BaseEntity entity = new BaseEntity("PK", "RK");
                table.Execute(TableOperation.Insert(entity));

                SharedAccessTablePolicy policy = new SharedAccessTablePolicy()
                {
                    SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
                    SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
                    Permissions = SharedAccessTablePermissions.Delete,
                };

                string sasToken = table.GetSharedAccessSignature(policy);
                StorageCredentials creds = new StorageCredentials(sasToken);
                CloudTable sasTable = new CloudTable(table.Uri, creds);
                TestHelper.ExpectedException(
                    () => sasTable.Execute(TableOperation.Insert(new BaseEntity("PK", "RK2"))),
                    "Try to insert an entity when SAS doesn't allow inserts",
                    HttpStatusCode.Forbidden);

                sasTable.Execute(TableOperation.Delete(entity));

                SharedAccessTablePolicy policy2 = new SharedAccessTablePolicy()
                {
                    SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
                    SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
                    Permissions = SharedAccessTablePermissions.Delete | SharedAccessTablePermissions.Add,
                };

                string sasToken2 = table.GetSharedAccessSignature(policy2);
                creds.UpdateSASToken(sasToken2);

                sasTable = new CloudTable(table.Uri, creds);

                sasTable.Execute(TableOperation.Insert(new BaseEntity("PK", "RK2")));

            }
            finally
            {
                table.DeleteIfExists();
            }
        }
開發者ID:rwalka,項目名稱:azure-storage-net,代碼行數:49,代碼來源:TableSasUnitTests.cs

示例10: CalculateMADataToAzure

        private void CalculateMADataToAzure(CloudTable table, string azureTableStockCode, int MA)
        {
            DateTime startingDate = DateTime.FromFileTimeUtc(0);
            TableOperation retrieveStockEntityStatus = TableOperation.Retrieve<StockEntityStatus>("status-" + azureTableStockCode, "status");
            var stockEntityStatus = (StockEntityStatus)table.Execute(retrieveStockEntityStatus).Result;
            if (stockEntityStatus != null)
            {
                startingDate = stockEntityStatus.GetLatestMAStartDate(MA);
                Console.WriteLine("Latest starting date for MA{0} is on {1}", MA, startingDate.ToString("yyyy-MM-dd"));
            }

            string pkFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, azureTableStockCode);
            string rkLowerFilter = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, startingDate.ToString("yyyy-MM-dd"));
            string combinedFilter = TableQuery.CombineFilters(pkFilter, TableOperators.And, rkLowerFilter);
            TableQuery<StockEntity> query = new TableQuery<StockEntity>().Where(combinedFilter);
            var sortedStockEntities = table.ExecuteQuery<StockEntity>(query).OrderBy(entity => entity.Date).ToList();

            if (sortedStockEntities.LongCount() >= MA)
            {
                long totalCountToUpload = sortedStockEntities.LongCount();
                long currentCountUploaded = 0;

                Queue<double> maData = new Queue<double>();
                TableBatchOperation tableBatchOperation = new TableBatchOperation();
                foreach (var stockEntity in sortedStockEntities)
                {
                    maData.Enqueue(stockEntity.Close);
                    if (maData.Count == MA)
                    {
                        double sum = 0;
                        foreach (var data in maData)
                        {
                            sum += data;
                        }
                        stockEntity.SetMA(MA, sum / MA);

                        tableBatchOperation.Add(TableOperation.InsertOrMerge(stockEntity));
                        maData.Dequeue();
                    }
                    if (tableBatchOperation.Count == 100)
                    {
                        table.ExecuteBatch(tableBatchOperation);
                        currentCountUploaded += 100;
                        Console.WriteLine("{0}/{1} entities uploaded...", currentCountUploaded, totalCountToUpload);
                        tableBatchOperation.Clear();
                    }
                }
                if (tableBatchOperation.Count > 0)
                {
                    table.ExecuteBatch(tableBatchOperation);
                    currentCountUploaded += tableBatchOperation.Count;
                    Console.WriteLine("{0}/{1} entities uploaded...", currentCountUploaded, totalCountToUpload);
                }

                sortedStockEntities.Reverse();
                if (sortedStockEntities == null)
                {
                    stockEntityStatus = new StockEntityStatus(azureTableStockCode);
                }
                stockEntityStatus.SetLatestMAStartDate(MA, sortedStockEntities[MA - 2].Date);
                table.Execute(TableOperation.InsertOrMerge(stockEntityStatus));
            }
        }
開發者ID:weimingqing,項目名稱:stockdatabase,代碼行數:63,代碼來源:StockProcessingAgent.cs

示例11: CloudTableSASWithAbsoluteUri

        public void CloudTableSASWithAbsoluteUri()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            CloudTable table = tableClient.GetTableReference(tableClient.BaseUri + GenerateRandomTableName());
            try
            {
                table.CreateIfNotExists();

                BaseEntity entity = new BaseEntity("PK", "RK");
                table.Execute(TableOperation.Insert(entity));

                SharedAccessTablePolicy policy = new SharedAccessTablePolicy()
                {
                    Permissions = SharedAccessTablePermissions.Delete,
                    SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
                    SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(10)
                };

                string sasToken = table.GetSharedAccessSignature(policy);
                StorageCredentials creds = new StorageCredentials(sasToken);

                CloudTable sasTable = new CloudTable(table.Uri, creds);
                sasTable.Execute(TableOperation.Delete(entity));
            }
            finally
            {
                table.DeleteIfExists();
            }
        }
開發者ID:jasonnewyork,項目名稱:azure-storage-net,代碼行數:30,代碼來源:TableSasUnitTests.cs

示例12: getWebpageInfo

        public PageInfo getWebpageInfo()
        {
            mappingTable = Azure.GetInstance().getTableReference("mappingtable");
            webpageInfo.title = "";
            HtmlNode node = root.SelectSingleNode("//title");
            if (node != null)
            {
                webpageInfo.title = node.InnerText;
            }

            string title = webpageInfo.title;
            string[] keywords = title.Split(' ');

            try
            {
                foreach (string keyword in keywords)
                {
                    mappingTable.Execute(TableOperation.Insert(new Mapping(keyword, url)));
                }
            }
            catch (StorageException) { }

            string datetime = null;
            node = root.SelectSingleNode("//meta[@http-equiv='last-modified']");
            if (node != null)
            {
                datetime = node.GetAttributeValue("content", null);
            }
            else
            {
                node = root.SelectSingleNode("//meta[@name='date']");
                if (node != null)
                {
                    datetime = node.GetAttributeValue("content", null);
                }
                else
                {
                    Match match = Regex.Match(html, @"<div>Posted:\s*[^<]+\s*;\s*Updated:\s*([^<]+)\s*</div>");
                    if (match.Success)
                    {
                        datetime = match.Groups[1].Value;
                    }
                    else
                    {
                        match = Regex.Match(html, @"<div>Posted:\s*([^<]+)\s*</div>");
                        if (match.Success)
                        {
                            datetime = match.Groups[1].Value;
                        }
                    }
                }
            }

            try
            {
                webpageInfo.date = DateTime.Parse(datetime);
            }
            catch (ArgumentNullException)
            {
                Trace.TraceInformation("Datetime not fetched for url: " + webpageInfo.url);
                throw new WebParseDatetimeException();
            }
            catch (FormatException)
            {
                Trace.TraceInformation("Datetime not parsable: " + datetime);
                throw new WebParseDatetimeException();
            }
            return webpageInfo;
        }
開發者ID:kxchiu,項目名稱:INFO344,代碼行數:69,代碼來源:[PA+4]+CNNPage.cs

示例13: InsertEntity

 public TableResult InsertEntity(CloudTable table, TableEntity entity)
 {
     TableOperation insertOperation = TableOperation.Insert(entity);
     return table.Execute(insertOperation);
 }
開發者ID:haiyangIt,項目名稱:Haiyang,代碼行數:5,代碼來源:TableDataAccess.cs

示例14: FindExistingLogin

 /// <summary>
 /// Finds an existing login.
 /// </summary>
 /// <param name="loginTable">the login table.</param>
 /// <param name="accountId">the account id.</param>
 /// <returns>A matching entity or null.</returns>
 private static LoginEntity FindExistingLogin(
     CloudTable loginTable,
     EmailAddress accountId)
 {
     TableOperation findExistingOperation = TableOperation.Retrieve<LoginEntity>(
         accountId.Domain,
         accountId.LocalPart);
     TableResult findExistingResult = loginTable.Execute(findExistingOperation);
     return findExistingResult.Result as LoginEntity;
 }
開發者ID:localtoast9001,項目名稱:independent-sts,代碼行數:16,代碼來源:AccountStore.cs

示例15: FindExistingOrganization

 /// <summary>
 /// Finds an existing organization by name.
 /// </summary>
 /// <param name="table">the organization table.</param>
 /// <param name="name">the organization name.</param>
 /// <returns>The matching entity or null.</returns>
 private static OrganizationEntity FindExistingOrganization(
     CloudTable table,
     string name)
 {
     TableOperation findExistingOperation = TableOperation.Retrieve<OrganizationEntity>(
         name,
         string.Empty);
     TableResult findExistingResult = table.Execute(findExistingOperation);
     return findExistingResult.Result as OrganizationEntity;
 }
開發者ID:localtoast9001,項目名稱:independent-sts,代碼行數:16,代碼來源:OrganizationStore.cs


注:本文中的Microsoft.WindowsAzure.Storage.Table.CloudTable.Execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。