简体   繁体   中英

Why is the Visual Studio 2013 Scaffolding different (Controller vs. WebApi) ?

For the normal read of all entities The Controller version is:

   public ActionResult Index()
    {
        var tmembers = db.tMembers.Include(t => t.tEducationType).Include(t => t.tRaceType).Include(t => t.tReligion);
        return View(tmembers.ToList());
    }

And the WebAPI is:

   public IQueryable<tMember> GettMembers()
    {
        return db.tMembers;
    }

Any idea why they are not the same ?

WebAPI returns IQueryable to support OData. If instead you want to just return JSON, set your service to serialize to JSON, and change the signature to public IEnumerable GetMembers()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM