MergeEntity() публичный Метод

public MergeEntity ( string tablename, string partkey, string rowkey, object>.Dictionary entity ) : TableStorageListDictResponse
tablename string
partkey string
rowkey string
entity object>.Dictionary
Результат TableStorageListDictResponse
Пример #1
0
        public void MergeEntityIsSuccessful()
        {
            DeleteEntityIsSuccessful();
            UpdateEntityIsSuccessful();
            var entity = new Dictionary <string, object>();

            entity.Add("PartitionKey", test_partition);
            entity.Add("RowKey", test_row);
            entity.Add("count", count + 2);
            Assert.AreEqual(HttpStatusCode.NoContent, ts.MergeEntity(test_table, test_partition, test_row, entity).http_response.status);
            var q = string.Format("$filter=(count eq {0}) and (dt eq datetime'{1}')",
                                  count + 2, test_dt.ToString(TableStorage.ISO_FORMAT_UTC));
            var ts_response = ts.QueryEntities(test_table, q);
            var dicts       = ts_response.list_dict_obj;

            Assert.That(dicts.Count == 1);
            Assert.That((int)dicts[0]["count"] == count + 2);
        }
Пример #2
0
        // try to insert a dict<str,obj> into table store
        // if conflict, try to merge or update
        public static TableStorageListDictResponse DictObjToTableStore(Operation operation, Dictionary <string, object> dict, string table, string partkey, string rowkey)
        {
            TableStorage ts     = MakeDefaultTableStorage();
            var          entity = new Dictionary <string, object>();

            entity.Add("PartitionKey", partkey);
            entity.Add("RowKey", rowkey);
            foreach (var key in dict.Keys)
            {
                if (key != "PartitionKey" && key != "RowKey")
                {
                    entity.Add(key, dict[key]);
                }
            }
            var response = ts.InsertEntity(table, entity);

            if (response.http_response.status != HttpStatusCode.Created)
            {
                switch (operation)
                {
                case Operation.update:
                    response = ts.UpdateEntity(table, partkey, rowkey, entity);
                    break;

                case Operation.merge:
                    response = ts.MergeEntity(table, partkey, rowkey, entity);
                    break;

                default:
                    GenUtils.LogMsg("warning", "DictToTableStore unexpected operation", operation.ToString());
                    break;
                }
                if (response.http_response.status != HttpStatusCode.NoContent)
                {
                    GenUtils.PriorityLogMsg("error", "DictToTableStore: " + operation, response.http_response.status.ToString() + ", " + response.http_response.message);
                }
            }
            return(response);
        }