This code in .Net Core 3.1, C# 8:
await dB.GetListAsync<OrigineDB>();
results in this error :
IAsyncEnumerable does not contain a definition for 'GetAwaiter'
The answer provided here : https://stackoverflow.com/a/60148747/4180382 didn't help me much since my method contains a yield and a loop like in the example.
What changes should I make ? I don't want to return a List.
async IAsyncEnumerable<T> GetListAsync<T>() where T : class, new()
{
cn = new SqlConnection(cs);
cn.Open();
cmd = new SqlCommand(nameProcStock, cn);
cmd.CommandType = CommandType.StoredProcedure;
if (parms != null)
foreach (KeyValuePair<string, object> kvp in parms)
cmd.Parameters.AddWithValue(kvp.Key, kvp.Value);
dr = await cmd.ExecuteReaderAsync();
while (dr.Read())
yield return ConvertToObject<T>();
}
GetObjectListAsync<OrigineDB>
andGetListAsync<T>
related to each other? – Pavel Anikhouski