public static async Task <bool> put(CloudTable nodeTable, NodeEntity entity) { await nodeTable.CreateIfNotExistsAsync(); try { TableOperation insertCacheOperation = TableOperation.InsertOrMerge(entity); await nodeTable.ExecuteAsync(insertCacheOperation); } catch { return(false); } return(true); }
public static async Task <bool> put(CloudTable nodeTable, string key) { await nodeTable.CreateIfNotExistsAsync(); try { NodeEntity newEntity = new NodeEntity(key); TableOperation insertEntityOperation = TableOperation.InsertOrMerge(newEntity); await nodeTable.ExecuteAsync(insertEntityOperation); } catch { return(false); } return(true); }
public static async Task <NodeEntity> get(CloudTable nodeTable, string key) { await nodeTable.CreateIfNotExistsAsync(); TableQuery <NodeEntity> rangeQuery = new TableQuery <NodeEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, $"{string.Empty}"), TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, $"{key}"))); var sessionRedirectFound = await nodeTable.ExecuteQuerySegmentedAsync(rangeQuery, null); if (sessionRedirectFound.Results.Count > 0) { NodeEntity entity = sessionRedirectFound.Results.ToArray()[0]; return(entity); } else { return(null); } }