public **HttpResponseMessage** GetContacts()
{
var result = db.Contacts().ToList();
return this.Request.CreateResponse(HttpStatusCode.BadRequest, result);
}
要使此调用 ASYNC,将“async Task<>”添加到返回调用是否足够:
public **async Task<HttpResponseMessage>** GetContacts()
{
var result = db.Contacts().ToList();
return this.Request.CreateResponse(HttpStatusCode.BadRequest, result);
}
或者因为它也在调用数据库,所以我也必须使所有/一些内部调用异步:
public **async Task<HttpResponseMessage>** GetContacts()
{
var result = **await** db.Contacts().ToList();
return this.Request.CreateResponse(HttpStatusCode.BadRequest, result);
}