I execute a query which returns a count, similar to "select count(1) from mytable". In my opinion this query should always return a resultset with one row OR throw an exception.
In my production logs I now see that under heavy load the QueryAsync sometimes returns an empty resultset (at the same time the log also shows connection errors/timeouts for other parallel requests).
I use this code:
protected virtual async Task<IEnumerable> TranQueryAsync(string query, object param)
{
return await _conn.QueryAsync(query, param, _runningTransaction, 30).ConfigureAwait(false);
}
My code calls First() on the resulting IEnumerable, but I get the exception that the sequence contains no elements. I think this is not ok and the QueryAsync should have thrown an exception.
I execute a query which returns a count, similar to "select count(1) from mytable". In my opinion this query should always return a resultset with one row OR throw an exception.
In my production logs I now see that under heavy load the QueryAsync sometimes returns an empty resultset (at the same time the log also shows connection errors/timeouts for other parallel requests).
I use this code:
protected virtual async Task<IEnumerable> TranQueryAsync(string query, object param)
{
return await _conn.QueryAsync(query, param, _runningTransaction, 30).ConfigureAwait(false);
}
My code calls First() on the resulting IEnumerable, but I get the exception that the sequence contains no elements. I think this is not ok and the QueryAsync should have thrown an exception.