public CommandEntity Add(string tableName, CommandEntity entity) { tableName.GuardAgainstNullOrEmpty(nameof(tableName)); entity.GuardAgainstNull(nameof(entity)); ExecuteInsert(tableName, entity.ToTableEntity()); return(Retrieve(tableName, entity.Id, entity.Metadata)); }
public CommandEntity Add(string containerName, CommandEntity entity) { containerName.GuardAgainstNullOrEmpty(nameof(containerName)); entity.GuardAgainstNull(nameof(entity)); var table = EnsureTable(containerName); SafeExecute(table, () => { table.Execute(TableOperation.Insert(entity.ToTableEntity(this.options))); }); return(Retrieve(containerName, entity.Id, entity.Metadata)); }
public CommandEntity Add(string containerName, CommandEntity entity) { containerName.GuardAgainstNullOrEmpty(nameof(containerName)); entity.GuardAgainstNull(nameof(entity)); var container = EnsureContainer(containerName); container.CreateItemAsync <dynamic>(entity.ToContainerEntity()).GetAwaiter().GetResult(); return(Retrieve(containerName, entity.Id, entity.Metadata)); }
public CommandEntity Replace(string containerName, string id, CommandEntity entity) { containerName.GuardAgainstNullOrEmpty(nameof(containerName)); id.GuardAgainstNull(nameof(id)); entity.GuardAgainstNull(nameof(entity)); var container = EnsureContainer(containerName); var result = container.UpsertItemAsync <dynamic>(entity.ToContainerEntity()).GetAwaiter().GetResult(); return(CommandEntity.FromCommandEntity(((JObject)result.Resource).FromContainerEntity(entity.Metadata), entity)); }
public CommandEntity Add(string containerName, CommandEntity entity) { containerName.GuardAgainstNullOrEmpty(nameof(containerName)); entity.GuardAgainstNull(nameof(entity)); var client = EnsureClient(); var key = CreateRowKey(containerName, entity); client.SetRangeInHash(key, entity.ToContainerProperties()); return(Retrieve(containerName, entity.Id, entity.Metadata)); }
public CommandEntity Replace(string containerName, string id, CommandEntity entity) { containerName.GuardAgainstNullOrEmpty(nameof(containerName)); id.GuardAgainstNull(nameof(id)); entity.GuardAgainstNull(nameof(entity)); var client = EnsureClient(); var keyValues = entity.ToContainerProperties(); var key = CreateRowKey(containerName, id); client.Remove(key); client.SetRangeInHash(key, keyValues); return(CommandEntity.FromCommandEntity(keyValues.FromContainerProperties(id, entity.Metadata), entity)); }