public async Task <IActionResult> GetDiscussions(Guid topicId, int page) { ZeroMin(ref page); const int pageSize = 20; var query = from p in Context.Discussions.Where(p => p.TopicId == topicId) join q in Context.Users on p.SenderId equals q.Id orderby p.CreatedAt descending select new { Discussion = p, Sender = q }; var data = await query.Skip(pageSize *page).Take(pageSize).ToListAsync(); var qdiscussions = data.Select(p => QDiscussion.NormalView(p.Discussion, p.Sender)).ToList(); return(Ok(qdiscussions)); }
public async Task <IActionResult> SearchDiscussions(string word, int page) { page = Math.Max(0, page); int pageSize = 20; var query = from p in Context.Discussions.AsNoTracking() where p.TextTsv.Matches(EF.Functions.WebSearchToTsQuery("testzhcfg", word)) join q in Context.Users on p.SenderId equals q.Id orderby p.TextTsv.RankCoverDensity(EF.Functions.WebSearchToTsQuery("testzhcfg", word)) descending select new { Discussion = p, Sender = q }; var data = await query.Skip(pageSize *page).Take(pageSize).ToListAsync(); var qdiscuss = data.Select(p => QDiscussion.NormalView(p.Discussion, p.Sender)).ToList(); return(Ok(qdiscuss)); }