I have the following use case:
- user requests creation of a widget. A new record is created with the details in a "request" partition in my storage table.
- when the request is fulfilled - the original request is deleted from the "request" partition and created anew in the "provisioned" partition.
When it comes to querying for a widget - I need to search both the request and provisioned partitions. From reading the docs, it seems that I can create filters? But it seems to be a lot of overhead because I know i will only ever have 1 record returned (hopefully, unless I have a bug). But it seems I have to add a lot of logic to handle pagination.
So far this is what i'm moving from:
entity = tableClient.GetEntity<TableEntity>(
"requested",
requestId);
To something like this:
//entity = tableClient.GetEntity<TableEntity>(
// "requested",
// requestId);
List<string> filters = new List<string>();
filters.Add($"PartitionKey eq '{"requested"}'");
filters.Add($"PartitionKey eq '{"provisioned"}'");
filters.Add($"RowKey eq '{requestId}'");
string filter = String.Join(" and ", filters);
//should only ever return one ... but ...
var entities = tableClient.QueryAsync<TableEntity>(filter);
await foreach (Page<TableEntity> page in entities.AsPages())
{
Console.WriteLine("This is a new page!");
foreach (TableEntity qEntity in page.Values)
{
Console.WriteLine($"i found this request: {qEntity.GetString("requestId")} with status: {"status"}");
}
}
This code presently doesn't work - will need to debug it. but I thought i'd check to see if there's an easier way to do this.
Thanks.