ElmcityUtils.TableStorage.DictObjToTableStore C# (CSharp) Method

DictObjToTableStore() public static method

public static DictObjToTableStore ( System.Operation operation, object>.Dictionary dict, string table, string partkey, string rowkey ) : TableStorageListDictResponse
operation System.Operation
dict object>.Dictionary
table string
partkey string
rowkey string
return TableStorageListDictResponse
        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;
        }

Usage Example

Beispiel #1
0
        public static void RememberUser(string host_addr, string host_name, string session_id, string mode, string target_field, string target_value)
        {
            var entity = new Dictionary <string, object>();

            entity["mode"]       = mode;
            entity[target_field] = target_value;
            entity["host_addr"]  = host_addr;
            entity["host_name"]  = host_name;
            TableStorage.DictObjToTableStore(TableStorage.Operation.update, entity, "sessions", "sessions", session_id);
        }
All Usage Examples Of ElmcityUtils.TableStorage::DictObjToTableStore