I'm having trouble getting an async-await call to work. I'm getting an error message that says ... does not contain a definition for 'GetAwaiter' ...
. Here's my code:
private async Task<IList<MyType>> Load()
{
SqlInsightDbProvider.RegisterProvider();
using (var conn = new SqlConnection("connString"))
{
//compiler error here
return await conn.QuerySqlAsync<MyType>("SELECT * FROM tbl");
}
}
That call to QuerySqlAsync
comes from InsightDB. The signature for it is:
public static Task<IList<T1>> QuerySqlAsync<T1>(
this IDbConnection connection,
string sql,
object parameters = null,
CommandBehavior commandBehavior = CommandBehavior.Default,
int? commandTimeout = default(int?),
IDbTransaction transaction = null,
CancellationToken? cancellationToken = default(CancellationToken?),
object outputParameters = null);
I have no experience with async-await and I thought that this would be a good, non-contrived example I can use to get familiar with it. I thought that an I/O operation like a database call is an archetypal example of when to use async-await. I've searched on StackOverflow for how to fix this, but I must not be understanding the answers I found.
Edit: Here's the error message I get: error CS1061: 'Task<IList<MyType>>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'Task<IList<MyType>>' could be found (are you missing a using directive or an assembly reference?)