An Azure service that stores structured NoSQL data in the cloud.
Hi Patrick,
You are seeing incorrect results because you are querying the table before your code has finished inserting all of the entities. Please test using modified code below:
public static async Task RunTest(TableClient client)
{
List<TableEntity> tableEntities = new List<TableEntity>();
// Create 1000 table entities
for (int i = 0; i < 1000; i++)
{
TableEntity entity = new TableEntity();
entity.PartitionKey = $"{new Random().Next(1, 10)}";
entity.RowKey = $"{Guid.NewGuid()}";
tableEntities.Add(entity);
}
await Parallel.ForEachAsync(tableEntities, async (entity, token) =>
{
await client.UpsertEntityAsync(entity);
});
for (int i = 0; i < 10; i++)
{
List<TableEntity> results = new();
var asyncdata = client.QueryAsync<TableEntity>(maxPerPage: 200).ConfigureAwait(false);
await foreach (TableEntity page in asyncdata)
{
results.Add(page);
}
Console.WriteLine($"Read entities :{results.Count}");
}
}
Please click Accept Answer and upvote if the above was helpful.
Thanks.
-TP