Untitled
unknown
plain_text
2 years ago
1.2 kB
7
Indexable
private async Task<int> CountCoursesAmount(string selectedDatabase, string selectedTableName, string idToChk)
{
int res = 0;
Microsoft.Azure.Cosmos.Container table;
try
{
table =
cosmosClient.GetContainer(selectedDatabase, selectedTableName);
}
catch
{
return 0;
}
try
{
Microsoft.Azure.Cosmos.ItemResponse<Student> requestedItem =
await table.ReadItemAsync<Student>(idToChk,
new Microsoft.Azure.Cosmos.PartitionKey(idToChk));
//Count the addresses of the current id
Student student = requestedItem.Resource;
if (student != null)
{
if (student.Courses != null)
{
res = student.Courses.Length;
}
}
}
catch
{
res = 0;
}
return res;
}Editor is loading...
Leave a Comment