protected virtual async Task<IEnumerable<T>> ExecuteAPI_SQLQuery_ObjectListAsync<T>(DB_ID db_id, string sqlQuery, object queryParameters){
try
{
string dbString = GetDBStringAsync(db_id);
using (DbConnection conn = new SqlConnection(dbString))
{
List<T> tResults = null;
tResults = await Task.FromResult((conn.QuerySqlAsync<T>(sqlQuery, queryParameters)).Result.ToList());
return tResults;
}
}
catch (Exception e)
{
}
After much searching the internet and trial and error I now have the above code compiling but it still seems to run synchronously. This uses insight.Database orm where querysqlasync is supported so I feel it is the use of Task.FromResult or Result.ToList may be waht is causing the issue.
I have ensured I am using a SQLConnection with Allow Asynchronous = true. But feel the problem lies with the above code despite it compiling. The issue I had and what lead me to construct it in the above way was around converting IList to Generic List.
Does anyone have any ideas for an alternative working solution?