【问题标题】:How to solve error int does not contain a definition for GetAwaiter .NET Core Web API如何解决错误 int 不包含 GetAwaiter .NET Core Web API 的定义
【发布时间】:2022-07-06 13:13:32
【问题描述】:

我在这段代码中调用了一个存储过程,该存储过程将根据其执行返回 1 或 0。

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

运行这段代码,我得到这个错误:

int 不包含 GetAwaiter 的定义

我在 Google 上检查了解决方案,它说我需要在存储过程调用结束时使用 .ToListAsync()。但是我的存储过程没有返回任何列表。

有人可以帮忙吗?

提前致谢。

【问题讨论】:

    标签: c# asynchronous .net-core entity-framework-core asp.net-core-webapi


    【解决方案1】:

    【讨论】:

    • 感谢您的回答。它奏效了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 2012-08-04
    相关资源
    最近更新 更多