public InsertEntity ( string tablename, object>.Dictionary |
||
tablename | string | |
entity | object>.Dictionary | |
return |
public void CreateEntityIsSuccessful() { ts.DeleteEntity(test_table, test_partition, test_row); HttpUtils.Wait(short_wait); if (ts.ExistsTable(test_table).boolean == false) { ts.CreateTable(test_table); } var entity = new Dictionary <string, object>(); entity.Add("PartitionKey", test_partition); entity.Add("RowKey", test_row); foreach (var key in test_dict.Keys) { entity.Add(key, test_dict[key]); } Assert.AreEqual(HttpStatusCode.Created, ts.InsertEntity(test_table, entity).http_response.status); }
// 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); }