10/16/2019 9:39:44 PM

The following will count all rows in the Posts table (or whatever table you want or map Posts to). The function is marked as async so it returns a Task and awaits the CountAsync method.

public async Task<int> Count() { var query = from posts in this._DbContext.Posts select posts.Id; return await query.CountAsync(); }