1
我试图包含关系数据与我的公司模型。当我不使用Include
时,我得到了我的答案,但是当我不包括时,我在Postman中得到了Could not get any response
。不能包含关系数据与实体框架
public async Task<IActionResult> Get(string with, string orderBy)
{
CustContext context = new CustContext();
var companies = context.Companies.Include(c => c.Stores).ToListAsync();
return Ok(companies);
}
我想在json
格式,它处理由它自身不包括在返回答案。
有人有什么不顺利的线索?
编辑
当我调试我看到companies
正确设置与Stores
在一起。返回结果时肯定有错误。
为什么不返回'任务'? –
dcg
我喜欢用'Ok()'函数。当返回'任务'时,是否有设置状态码的好方法? –
我相信当方法重新启动时,状态码是正确设置的,不是吗? – dcg