Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code in which I am calling a stored procedure and that stored procedure will return 1 or 0 based upon its execution.

public async Task<int> CreateData(int id, string name)
{
    return await _dbContext.Database.ExecuteSqlInterpolated($"execute spname {id}, {name}");                      
}

Running this code, I get this error:
Quote:
int does not contain a definition for GetAwaiter


What I have tried:

I checked for solution on Google and its saying I need to use .ToListAsync() at the end of the stored procedure call. But my stored procedure is not returning any list.
Posted
Comments
George Swan 6-Jul-22 2:56am    
It looks like you are awaiting a method that returns an int. It needs to return a Task.
Graeme_Grant 6-Jul-22 3:39am    
Is ExecuteSqlInterpolated meant to return an int? Could the result be null? Then it would be:
public async Task<int?> CreateData(int id, string name)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900