*sigh* The issue is that you are trying to await on the returned single object. Since that object has no awaiter because it is not a
Task
, you get that compile time error which tells you that it can't find the
GetAwaiter()
method.
The quickest path forward for you is to remove the
async/await
:
public int GetOrgIdByDeviceName(string deviceName)
{
return _context
.GetOrganisationID
.FromSqlRaw("SELECT OrgId = [dbo].[FcGetOrgIdByDeviceName]({0}) ", deviceName)
.Single();
}
If you really much have async functionality, then you need to use part of your original code to get the list asynchronously, and then once you have the list, just pull the single object from it.
public async Task<int> GetOrgIdByDeviceNameAsync(string deviceName)
{
var list = await _context
.GetOrganisationID
.FromSqlRaw("SELECT OrgId = [dbo].[FcGetOrgIdByDeviceName]({0}) ", deviceName)
.ToListAsync();
return list.Single();
}