I have the following function in a .NET Core 2.0 app.
public DataTable CallDb(string connStr, string sql)
{
var dt = new DataTable();
var da = new SqlDataAdapter(sql, connStr);
da.Fill(dt);
return dt;
}
How to convert it to an async function?
public async Task<DataTable> CallDb(string connStr, string sql)
{
var dt = new DataTable();
var da = new SqlDataAdapter(sql, connStr);
da.Fill(dt); // No FillAsync to await?
return dt;
}
I need to use DataTable
because the sql may return data with different schema. Any better way to handle the dynamical schema?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…