当前位置: 首页>>代码示例>>C#>>正文


C# TableBatchOperation.InsertOrReplace方法代码示例

本文整理汇总了C#中TableBatchOperation.InsertOrReplace方法的典型用法代码示例。如果您正苦于以下问题:C# TableBatchOperation.InsertOrReplace方法的具体用法?C# TableBatchOperation.InsertOrReplace怎么用?C# TableBatchOperation.InsertOrReplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableBatchOperation的用法示例。


在下文中一共展示了TableBatchOperation.InsertOrReplace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddVersion

 public async Task AddVersion(OwnershipRegistration registration, OwnershipOwner owner, string version)
 {
     CloudTableClient client = _account.CreateCloudTableClient();
     CloudTable table = client.GetTableReference(OwnershipTableName);
     TableBatchOperation batch = new TableBatchOperation();
     batch.InsertOrReplace(new TypedEntity(registration.GetKey(), owner.GetKey(), OwnerType));
     batch.InsertOrReplace(new TypedEntity(registration.GetKey(), version, PackageType));
     await table.ExecuteBatchAsync(batch);
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:9,代码来源:TableStorageRegistration.cs

示例2: SaveBootstrap

        static TableBatchOperation SaveBootstrap(IEnumerable<SearchModel> searchModel)
        {
            var batchOperation = new TableBatchOperation();
            foreach (var model in searchModel)
            {
                if (string.IsNullOrWhiteSpace(model.Url) || string.IsNullOrWhiteSpace(model.PartitionKey))
                {
                    throw new InvalidOperationException("We require a partition key, and row key");
                }
                batchOperation.InsertOrReplace(model);
            }

            return batchOperation;
        }
开发者ID:TerribleDev,项目名称:lmltfy,代码行数:14,代码来源:DatabaseRepository.cs

示例3: Load

        public void Load()
        {
            TableBatchManager.LogInfo("Load batch called");
            try
            {
            TableBatchOperation op = new TableBatchOperation();
            foreach (var e in Entities)
            {
                if (Merge)
                    op.InsertOrMerge(e);
                else
                    op.InsertOrReplace(e);
            }
            Table.ExecuteBatch(op);
            TableBatchManager.LogInfo("exec batch");
            }
            catch(Exception ex)
            {
                TableBatchManager.LogError("Error: " + ex);

            }
        }
开发者ID:adhurwit,项目名称:AzureStorageTools,代码行数:22,代码来源:Batch.cs

示例4: ProcessPlayerGame

        public static void ProcessPlayerGame(Int64 playerId, PlayerGameData gameData, Guid gameId, Int64 gameSeconds)
        {
            // Create the batch operation.
            TableBatchOperation batchOperation = new TableBatchOperation();

            //TODO: Get Player Row
            PlayerEntity player = PlayerEntity.GetPlayerEntity(playerId);
            batchOperation.InsertOrReplace(player);

            //Update Player Entity with Game Data
            player.TotalDeaths += gameData.Deaths;
            player.TotalKills += gameData.Kills;
            player.TotalPoints += gameData.Points;
            player.TotalWins += gameData.Win ? 1 : 0;
            player.TotalGames += 1;
            player.TotalSecondsPlayed += gameSeconds;

            //Create PlayerGame Row
            PlayerGameEntity playerGame = new PlayerGameEntity(playerId, gameId)
            {
                Points = gameData.Points,
                Win = gameData.Win,
                Kills = gameData.Kills,
                Deaths = gameData.Deaths,
                GameDuration = gameSeconds
            };
            batchOperation.Insert(playerGame);

            try
            {
                StorageManager.Instance.PlayersTable.ExecuteBatch(batchOperation);
            }
            catch (Exception ex)
            {
                //TODO: handle exception, check if its because an entity already existed.
                //This means we've already handled this data.
            }
        }
开发者ID:CaitieM20,项目名称:DotNetConf,代码行数:38,代码来源:PlayerHelper.cs

示例5: AddSubscriptions

        public async Task<bool> AddSubscriptions(IEnumerable<UserSubscription> subscriptionsToAdd)
        {
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable userSubscriptionsTable = 
                tableClient.GetTableReference("userSubscriptions");

            var tableExists = await userSubscriptionsTable.ExistsAsync();
            if (!tableExists)
            {
                await userSubscriptionsTable.CreateIfNotExistsAsync();
            }

            TableBatchOperation batchOperation = new TableBatchOperation();
            foreach (var subscription in subscriptionsToAdd)
            {
                UserSubscriptionEntity userSubscriptionEntity =
                    new UserSubscriptionEntity(subscription.UserId, subscription.FriendId);
                batchOperation.InsertOrReplace(userSubscriptionEntity);
            }
            await userSubscriptionsTable.ExecuteBatchAsync(batchOperation);

            return true;
        }
开发者ID:hoopkjaz,项目名称:AngularAzureDemo,代码行数:23,代码来源:UserSubscriptionRepository.cs

示例6: DoTableBatchOperationsWithEmptyKeysAsync

        private async Task DoTableBatchOperationsWithEmptyKeysAsync(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;

            // Insert Entity
            DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "", RowKey = "" };
            ent.Properties.Add("foo2", new EntityProperty("bar2"));
            ent.Properties.Add("foo", new EntityProperty("bar"));
            TableBatchOperation batch = new TableBatchOperation();
            batch.Insert(ent);
            await currentTable.ExecuteBatchAsync(batch);

            // Retrieve Entity
            TableBatchOperation retrieveBatch = new TableBatchOperation();
            retrieveBatch.Retrieve(ent.PartitionKey, ent.RowKey);
            TableResult result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();

            DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
            Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
            Assert.AreEqual(ent.Properties.Count, retrievedEntity.Properties.Count);
            Assert.AreEqual(ent.Properties["foo"].StringValue, retrievedEntity.Properties["foo"].StringValue);
            Assert.AreEqual(ent.Properties["foo"], retrievedEntity.Properties["foo"]);
            Assert.AreEqual(ent.Properties["foo2"].StringValue, retrievedEntity.Properties["foo2"].StringValue);
            Assert.AreEqual(ent.Properties["foo2"], retrievedEntity.Properties["foo2"]);

            // InsertOrMerge
            DynamicTableEntity insertOrMergeEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey);
            insertOrMergeEntity.Properties.Add("foo3", new EntityProperty("value"));
            batch = new TableBatchOperation();
            batch.InsertOrMerge(insertOrMergeEntity);
            await currentTable.ExecuteBatchAsync(batch);

            result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(insertOrMergeEntity.Properties["foo3"], retrievedEntity.Properties["foo3"]);

            // InsertOrReplace
            DynamicTableEntity insertOrReplaceEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey);
            insertOrReplaceEntity.Properties.Add("prop2", new EntityProperty("otherValue"));
            batch = new TableBatchOperation();
            batch.InsertOrReplace(insertOrReplaceEntity);
            await currentTable.ExecuteBatchAsync(batch);

            result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(1, retrievedEntity.Properties.Count);
            Assert.AreEqual(insertOrReplaceEntity.Properties["prop2"], retrievedEntity.Properties["prop2"]);

            // Merge
            DynamicTableEntity mergeEntity = new DynamicTableEntity(retrievedEntity.PartitionKey, retrievedEntity.RowKey) { ETag = retrievedEntity.ETag };
            mergeEntity.Properties.Add("mergeProp", new EntityProperty("merged"));
            batch = new TableBatchOperation();
            batch.Merge(mergeEntity);
            await currentTable.ExecuteBatchAsync(batch);

            // Retrieve Entity & Verify Contents
            result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();
            retrievedEntity = result.Result as DynamicTableEntity;

            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(mergeEntity.Properties["mergeProp"], retrievedEntity.Properties["mergeProp"]);

            // Replace
            DynamicTableEntity replaceEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey) { ETag = retrievedEntity.ETag };
            replaceEntity.Properties.Add("replaceProp", new EntityProperty("replace"));
            batch = new TableBatchOperation();
            batch.Replace(replaceEntity);
            await currentTable.ExecuteBatchAsync(batch);

            // Retrieve Entity & Verify Contents
            result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(replaceEntity.Properties.Count, retrievedEntity.Properties.Count);
            Assert.AreEqual(replaceEntity.Properties["replaceProp"], retrievedEntity.Properties["replaceProp"]);

            // Delete Entity
            batch = new TableBatchOperation();
            batch.Delete(retrievedEntity);
            await currentTable.ExecuteBatchAsync(batch);

            // Retrieve Entity
            result = (await currentTable.ExecuteBatchAsync(retrieveBatch)).First();
            Assert.IsNull(result.Result);
        }
开发者ID:vinaysh-msft,项目名称:azure-storage-net,代码行数:89,代码来源:TableBatchOperationTaskTest.cs

示例7: DoTableBatchInsertOrReplaceAsync

        private async Task DoTableBatchInsertOrReplaceAsync(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;

            // Insert Or Replace with no pre-existing entity
            DynamicTableEntity insertOrReplaceEntity = new DynamicTableEntity("insertOrReplace entity", "foo" + format.ToString());
            insertOrReplaceEntity.Properties.Add("prop1", new EntityProperty("value1"));

            TableBatchOperation batch = new TableBatchOperation();
            batch.InsertOrReplace(insertOrReplaceEntity);
            await currentTable.ExecuteBatchAsync(batch);

            // Retrieve Entity & Verify Contents
            TableResult result = await currentTable.ExecuteAsync(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey));
            DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(insertOrReplaceEntity.Properties.Count, retrievedEntity.Properties.Count);

            DynamicTableEntity replaceEntity = new DynamicTableEntity(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey);
            replaceEntity.Properties.Add("prop2", new EntityProperty("value2"));

            TableBatchOperation batch2 = new TableBatchOperation();
            batch2.InsertOrReplace(replaceEntity);
            await currentTable.ExecuteBatchAsync(batch2);

            // Retrieve Entity & Verify Contents
            result = await currentTable.ExecuteAsync(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey));
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(1, retrievedEntity.Properties.Count);
            Assert.AreEqual(replaceEntity.Properties["prop2"], retrievedEntity.Properties["prop2"]);
        }
开发者ID:vinaysh-msft,项目名称:azure-storage-net,代码行数:32,代码来源:TableBatchOperationTaskTest.cs

示例8: DoTableBatchInsertOrReplaceEncryption

        private void DoTableBatchInsertOrReplaceEncryption(TablePayloadFormat format)
        {
            tableClient.DefaultRequestOptions.PayloadFormat = format;

            // Create the Key to be used for wrapping.
            SymmetricKey aesKey = new SymmetricKey("symencryptionkey");

            TableRequestOptions options = new TableRequestOptions()
            {
                EncryptionPolicy = new TableEncryptionPolicy(aesKey, null),

                EncryptionResolver = (pk, rk, propName) =>
                {
                    if (propName == "A" || propName == "B")
                    {
                        return true;
                    }

                    return false;
                }
            };

            // Insert Or Replace with no pre-existing entity
            DynamicTableEntity insertOrReplaceEntity = new DynamicTableEntity("insertOrReplace entity", "foo" + format.ToString());
            insertOrReplaceEntity.Properties.Add("A", new EntityProperty("a"));

            TableBatchOperation batch = new TableBatchOperation();
            batch.InsertOrReplace(insertOrReplaceEntity);
            currentTable.ExecuteBatch(batch, options);

            // Retrieve Entity & Verify Contents
            // Create the resolver to be used for unwrapping.
            DictionaryKeyResolver resolver = new DictionaryKeyResolver();
            resolver.Add(aesKey);

            TableRequestOptions retrieveOptions = new TableRequestOptions() { EncryptionPolicy = new TableEncryptionPolicy(null, resolver) };
            TableResult result = currentTable.Execute(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey), retrieveOptions);
            DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(insertOrReplaceEntity.Properties.Count, retrievedEntity.Properties.Count);

            DynamicTableEntity replaceEntity = new DynamicTableEntity(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey);
            replaceEntity.Properties.Add("B", new EntityProperty("b"));

            TableBatchOperation batch2 = new TableBatchOperation();
            batch2.InsertOrReplace(replaceEntity);
            currentTable.ExecuteBatch(batch2, options);

            // Retrieve Entity & Verify Contents
            result = currentTable.Execute(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey), retrieveOptions);
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(1, retrievedEntity.Properties.Count);
            Assert.AreEqual(replaceEntity.Properties["B"], retrievedEntity.Properties["B"]);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:55,代码来源:TableEntityEncryptionTests.cs

示例9: TableBatchInsertOrReplaceAPM

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

            // Insert Or Replace with no pre-existing entity
            DynamicTableEntity insertOrReplaceEntity = new DynamicTableEntity("insertOrReplace entity", "foo");
            insertOrReplaceEntity.Properties.Add("prop1", new EntityProperty("value1"));

            TableBatchOperation batch = new TableBatchOperation();
            batch.InsertOrReplace(insertOrReplaceEntity);

            using (ManualResetEvent evt = new ManualResetEvent(false))
            {
                IAsyncResult asyncRes = null;
                currentTable.BeginExecuteBatch(batch, (res) =>
                {
                    asyncRes = res;
                    evt.Set();
                }, null);
                evt.WaitOne();

                currentTable.EndExecuteBatch(asyncRes);
            }

            // Retrieve Entity & Verify Contents
            TableResult result = currentTable.Execute(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey));
            DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(insertOrReplaceEntity.Properties.Count, retrievedEntity.Properties.Count);

            DynamicTableEntity replaceEntity = new DynamicTableEntity(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey);
            replaceEntity.Properties.Add("prop2", new EntityProperty("value2"));

            TableBatchOperation batch2 = new TableBatchOperation();
            batch2.InsertOrReplace(replaceEntity);
            using (ManualResetEvent evt = new ManualResetEvent(false))
            {
                IAsyncResult asyncRes = null;
                currentTable.BeginExecuteBatch(batch2, (res) =>
                {
                    asyncRes = res;
                    evt.Set();
                }, null);
                evt.WaitOne();

                currentTable.EndExecuteBatch(asyncRes);
            }

            // Retrieve Entity & Verify Contents
            result = currentTable.Execute(TableOperation.Retrieve(insertOrReplaceEntity.PartitionKey, insertOrReplaceEntity.RowKey));
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(1, retrievedEntity.Properties.Count);
            Assert.AreEqual(replaceEntity.Properties["prop2"], retrievedEntity.Properties["prop2"]);
        }
开发者ID:udooz,项目名称:azure-sdk-for-net,代码行数:55,代码来源:TableBatchOperationTest.cs

示例10: TableBatchOperationsWithEmptyKeys

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

            // Insert Entity
            DynamicTableEntity ent = new DynamicTableEntity() { PartitionKey = "", RowKey = "" };
            ent.Properties.Add("foo2", new EntityProperty("bar2"));
            ent.Properties.Add("foo", new EntityProperty("bar"));
            TableBatchOperation batch = new TableBatchOperation();
            batch.Insert(ent);
            currentTable.ExecuteBatch(batch);

            // Retrieve Entity
            TableBatchOperation retrieveBatch = new TableBatchOperation();
            retrieveBatch.Retrieve(ent.PartitionKey, ent.RowKey);
            TableResult result = currentTable.ExecuteBatch(retrieveBatch).First();

            DynamicTableEntity retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(ent.PartitionKey, retrievedEntity.PartitionKey);
            Assert.AreEqual(ent.RowKey, retrievedEntity.RowKey);
            Assert.AreEqual(ent.Properties.Count, retrievedEntity.Properties.Count);
            Assert.AreEqual(ent.Properties["foo"].StringValue, retrievedEntity.Properties["foo"].StringValue);
            Assert.AreEqual(ent.Properties["foo"], retrievedEntity.Properties["foo"]);
            Assert.AreEqual(ent.Properties["foo2"].StringValue, retrievedEntity.Properties["foo2"].StringValue);
            Assert.AreEqual(ent.Properties["foo2"], retrievedEntity.Properties["foo2"]);

            // InsertOrMerge
            DynamicTableEntity insertOrMergeEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey);
            insertOrMergeEntity.Properties.Add("foo3", new EntityProperty("value"));
            batch = new TableBatchOperation();
            batch.InsertOrMerge(insertOrMergeEntity);
            currentTable.ExecuteBatch(batch);

            result = currentTable.ExecuteBatch(retrieveBatch).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(insertOrMergeEntity.Properties["foo3"], retrievedEntity.Properties["foo3"]);

            // InsertOrReplace
            DynamicTableEntity insertOrReplaceEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey);
            insertOrReplaceEntity.Properties.Add("prop2", new EntityProperty("otherValue"));
            batch = new TableBatchOperation();
            batch.InsertOrReplace(insertOrReplaceEntity);
            currentTable.ExecuteBatch(batch);

            result = currentTable.ExecuteBatch(retrieveBatch).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(1, retrievedEntity.Properties.Count);
            Assert.AreEqual(insertOrReplaceEntity.Properties["prop2"], retrievedEntity.Properties["prop2"]);

            // Merge
            DynamicTableEntity mergeEntity = new DynamicTableEntity(retrievedEntity.PartitionKey, retrievedEntity.RowKey) { ETag = retrievedEntity.ETag };
            mergeEntity.Properties.Add("mergeProp", new EntityProperty("merged"));
            batch = new TableBatchOperation();
            batch.Merge(mergeEntity);
            currentTable.ExecuteBatch(batch);

            // Retrieve Entity & Verify Contents
            result = currentTable.ExecuteBatch(retrieveBatch).First();
            retrievedEntity = result.Result as DynamicTableEntity;

            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(mergeEntity.Properties["mergeProp"], retrievedEntity.Properties["mergeProp"]);

            // Replace
            DynamicTableEntity replaceEntity = new DynamicTableEntity(ent.PartitionKey, ent.RowKey) { ETag = retrievedEntity.ETag };
            replaceEntity.Properties.Add("replaceProp", new EntityProperty("replace"));
            batch = new TableBatchOperation();
            batch.Replace(replaceEntity);
            currentTable.ExecuteBatch(batch);

            // Retrieve Entity & Verify Contents
            result = currentTable.ExecuteBatch(retrieveBatch).First();
            retrievedEntity = result.Result as DynamicTableEntity;
            Assert.IsNotNull(retrievedEntity);
            Assert.AreEqual(replaceEntity.Properties.Count, retrievedEntity.Properties.Count);
            Assert.AreEqual(replaceEntity.Properties["replaceProp"], retrievedEntity.Properties["replaceProp"]);

            // Delete Entity
            batch = new TableBatchOperation();
            batch.Delete(retrievedEntity);
            currentTable.ExecuteBatch(batch);

            // Retrieve Entity
            result = currentTable.ExecuteBatch(retrieveBatch).First();
            Assert.IsNull(result.Result);
        }
开发者ID:udooz,项目名称:azure-sdk-for-net,代码行数:89,代码来源:TableBatchOperationTest.cs

示例11: TableBatchAllSupportedOperationsSync

        public void TableBatchAllSupportedOperationsSync()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            TableBatchOperation batch = new TableBatchOperation();
            string pk = Guid.NewGuid().ToString();

            // insert
            batch.Insert(GenerateRandomEnitity(pk));

            // delete
            {
                DynamicTableEntity entity = GenerateRandomEnitity(pk);
                currentTable.Execute(TableOperation.Insert(entity));
                batch.Delete(entity);
            }

            // replace
            {
                DynamicTableEntity entity = GenerateRandomEnitity(pk);
                currentTable.Execute(TableOperation.Insert(entity));
                batch.Replace(entity);
            }

            // insert or replace
            {
                DynamicTableEntity entity = GenerateRandomEnitity(pk);
                currentTable.Execute(TableOperation.Insert(entity));
                batch.InsertOrReplace(entity);
            }

            // merge
            {
                DynamicTableEntity entity = GenerateRandomEnitity(pk);
                currentTable.Execute(TableOperation.Insert(entity));
                batch.Merge(entity);
            }

            // insert or merge
            {
                DynamicTableEntity entity = GenerateRandomEnitity(pk);
                currentTable.Execute(TableOperation.Insert(entity));
                batch.InsertOrMerge(entity);
            }

            IList<TableResult> results = currentTable.ExecuteBatch(batch);

            Assert.AreEqual(results.Count, 6);

            IEnumerator<TableResult> enumerator = results.GetEnumerator();
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.Created);
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.NoContent);
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.NoContent);
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.NoContent);
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.NoContent);
            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current.HttpStatusCode, (int)HttpStatusCode.NoContent);
        }
开发者ID:udooz,项目名称:azure-sdk-for-net,代码行数:62,代码来源:TableBatchOperationTest.cs

示例12: PersistQueryTable

 private void PersistQueryTable(IEnumerable<TwitterSearchRow> queries)
 {
     var batchOperation = new TableBatchOperation();
     foreach(var query in queries)
     {
         batchOperation.InsertOrReplace(query);
     }
     MetadataTable.ExecuteBatch(batchOperation);
 }
开发者ID:moften,项目名称:twitterbot,代码行数:9,代码来源:WorkerRole.cs

示例13: SyncTableSince

        private async Task SyncTableSince(CloudTable table, DateTimeOffset timestamp)
        {
            var query = new TableQuery<DynamicTableEntity>
                            {
                                FilterString = TableQuery.GenerateFilterConditionForDate("Timestamp", "gt", timestamp),
                            };

            IList<DynamicTableEntity> allFuckingEntities = await table.ExecuteQueryAsync(
                query, _token, list => Console.WriteLine("loaded {0} rows", list.Count));

            CloudTable dstTable = _dstClient.GetTableReference(table.Name);
            await dstTable.CreateIfNotExistsAsync();

            int n = 0;
            DateTimeOffset maxSourceTs = timestamp;

            foreach (var batch1 in allFuckingEntities.GroupBy(x => x.PartitionKey))
            {
                if (_token.IsCancellationRequested)
                    return;

                foreach (var batch2 in batch1.Batch(100))
                {
                    if (_token.IsCancellationRequested)
                        return;

                    var op = new TableBatchOperation();

                    foreach (DynamicTableEntity entity in batch2)
                    {
                        op.InsertOrReplace(entity);

                        if (entity.Timestamp > maxSourceTs)
                        {
                            maxSourceTs = entity.Timestamp;
                        }
                    }

                    await dstTable.ExecuteBatchAsync(op, _token);

                    n += Math.Min(op.Count, 100);
                    Console.WriteLine("sent {0} rows", n);
                }
            }

            _timestamps[table] = maxSourceTs;
        }
开发者ID:glueckkanja,项目名称:tasync,代码行数:47,代码来源:Syncer.cs

示例14: SaveInfo

        private async Task SaveInfo()
        {
            CloudTable metatable = _dstClient.GetTableReference(MetatableName);

            Console.WriteLine("new destination status");

            var op = new TableBatchOperation();

            foreach (var batch in _timestamps.OrderBy(x => x.Key.Name).Batch(100))
            {
                foreach (var item in batch)
                {
                    var entity = new DynamicTableEntity("SyncTimestamps", item.Key.Name);
                    entity.Properties["SourceTimestamp"] = new EntityProperty(item.Value);
                    op.InsertOrReplace(entity);

                    Console.WriteLine("{0,-40}{1}", item.Key.Name, item.Value);
                }

                await metatable.ExecuteBatchAsync(op, _token);
            }
        }
开发者ID:glueckkanja,项目名称:tasync,代码行数:22,代码来源:Syncer.cs

示例15: CommitChanges

        public int CommitChanges()
        {
            if (string.IsNullOrEmpty(this.token))
                return 0;

            if(ScoreItems.Count > 0)
            {
                TableBatchOperation batch = new TableBatchOperation();
                ScoreItems.ToList().ForEach(x =>
                {
                    batch.InsertOrReplace(x.Value);
                });
                eventScoreTable.ExecuteBatch(batch);
            }

            TableQuery<EventScoreItem> query = new TableQuery<EventScoreItem>()
                .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, this.token));

            var eventScore = eventScoreTable.ExecuteQuery(query).Sum(x=>x.Score);

            var totalItem = new EventScoreItem
            {
                PartitionKey = dddEventId.ToString(),
                RowKey = this.token,
                DDDEventId = dddEventId,
                UserName = userName,
                Score = eventScore
            };

            TableOperation insert = TableOperation.InsertOrReplace(totalItem);
            eventScoreTable.Execute(insert);

            return eventScore;
        }
开发者ID:RossDScott,项目名称:PocketDDD,代码行数:34,代码来源:EventScoreService.cs


注:本文中的TableBatchOperation.InsertOrReplace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。