【发布时间】:2020-06-30 11:05:39
【问题描述】:
我的 asp.net 核心 mvc 中有以下代码:-
var result = await _context.Settings.SingleOrDefaultAsync(a => a.Name.ToLower() == "noofvisits").Result.Value;
但我得到了这个错误:-
Error CS1061 'string' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
那么为什么我会收到这个错误? 谢谢
【问题讨论】:
-
嗨@test test,只要使用
var result = await _context.Settings.SingleOrDefaultAsync(a => a.Name.ToLower() == "noofvisits");就可以得到name等于noofvisits的值。 -
嗨@test test,我的回答对您解决问题有帮助吗?
标签: asp.net-core asynchronous .net-core asp.net-core-mvc