I'm trying to execute the SQL query in async and want to return the result but it's not returning the data, not sure what I'm missing.
public async Task<string> AsyncSBSystemApps()
{
using (var scope = _scopeFactory.CreateScope())
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(@"SELECT
a.app_guid as AppGuid,
a.name as AppName,
a.state as AppState,
a.created_at as AppCreatedAt,
a.updated_at as AppUpdatedAt,
a.foundation as AppFoundation,
s.name as SpaceName,
o.name as OrgName
FROM
apps as a
INNER JOIN
spaces as s ON a.space_guid = s.space_guid
INNER JOIN
organizations as o ON s.org_guid = o.org_guid
where s.name = 'system' and o.name = 'system' and a.foundation = 2", connection);
await connection.OpenAsync();
string result = (string)command.ExecuteScalar() ;
return result;
}
}