public async Task GetItemCount()

in Serverless/Serverless Web App with React, DynamoDb, and X-Ray/DynamoDBSvcLib/DynamoDBSvcLib/DBDataService.cs [79:98]


            public async Task<int> GetItemCount<T>()
            {
                int totalItems = 0;
                if (dynamoDBContext == null)
                {
                    dynamoDBContext = new DynamoDBContext(dynamoDBClient);
                }

                try
                {   //try to re-write to avoid doing full table scan as performance costs are extensive. Atomic counter table maintaining one additional table on dynamodb? NK
                    var itemBatch = dynamoDBContext.CreateBatchGet<T>();
                    await itemBatch.ExecuteAsync();
                    totalItems = itemBatch.Results.Count;

                }
                catch (AmazonDynamoDBException dbException) { Console.WriteLine(dbException.Message); }
                catch (AmazonServiceException dbSvcException) { Console.WriteLine(dbSvcException.Message); }

                return totalItems;
            }