Reputation: 81
Is there any way in table storage to read and then update a record? For example in SQL server I would use a query like this:
UPDATE table
SET
testValue = 1
OUTPUT
inserted.columnA,
inserted.columnB,
inserted.columnC
WHERE
testValue = 0
Currently my code looks like this:
var filter = "testValue eq 0";
var rangeQuery = new TableQuery<AzStorageEntityAdapter<T>>().Where(filter);
var result = _cloudTable.ExecuteQuery(rangeQuery);
var azStorageEntities = result.ToList();
IList<T> results = azStorageEntities.Select(r => r.InnerObject).ToList();
Is there some way to add a update clause along with my where clause when it reads the values that meet the filters criteria that 'testValue' is also updated to 1?
Upvotes: 1
Views: 387
Reputation: 136196
Unfortunately it is not possible in a single operation.
You must first fetch an entity (1st operation), update it and then save it back in the table (2nd operation).
Upvotes: 1