In the code below, due to the interface, the class LazyBar must return a task from its method (and for argument\'s sake can\'t be changed). If LazyBar
If you are using generics, all answer will give us compile error. You can use return default(T);. Sample below to explain further.
public async Task GetItemAsync(string id)
{
try
{
var response = await this._container.ReadItemAsync(id, new PartitionKey(id));
return response.Resource;
}
catch (CosmosException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return default(T);
}
}