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