📜  mvc 列表到 jsonresult - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:46.859000             🧑  作者: Mango

代码示例1
[HttpPost]
public JsonResult GetAreasForCompany(int companyId)
{
  var areas = context.Areas
    .Where(x => x.Company.CompanyId == companyId)
    .Select(a => new
    {
      AreaId = a.AreaId,
      Title = a.Title
    });
  return Json(areas);
}