asp.net - How can I do an async fetch of all the data from an entity with EF6.1? -
i using webapi , tried scaffold controller. method came fetch id:
// get: api/examstatus/5 [responsetype(typeof(examstatus))] public async task<ihttpactionresult> getexamstatus(int id) { examstatus examstatus = await db.examstatus.findasync(id); if (examstatus == null) { return notfound(); } return ok(examstatus); }
what if wanted async select of data examstatus entity? can explain how can this?
you try .tolistasync
extension method:
[responsetype(typeof(list<examstatus>))] public async task<ihttpactionresult> getexamstatuses() { var result = await db.examstatus.tolistasync(); return ok(result); }
obviously select rows in database , serialize them response.
Comments
Post a Comment