daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ApplicationDbContext.AddMessage(Message message);
  2.    
  3. threadViewModel.Materials = materialsQuery.OrderByDescending(x => x.LastActivity)
  4.  
  5.  
  6. .Select(x => new TopicInfoViewModel()
  7. {
  8.     Id = x.Id,
  9.     Title = x.Title,
  10.     MessagesCount = x.Messages.Count(m=>!m.IsDeleted),
  11.     AuthorName = x.Author.UserName,
  12.     PublishDate = x.PublishDate,
  13.     LastMessageId = x.LastMessageId,
  14.     LastMessagePublishDate =
  15.         x.LastMessageId.HasValue ? (DateTime?) x.LastMessage.PublishDate : null,
  16.     CategoryName = x.Category.Name,
  17.     LastMessageAuthorName = x.LastMessage.Author.UserName
  18. })
  19.    
  20. migrationBuilder.Sql("CREATE TRIGGER ...");
  21.    
  22. public IReadOnlyCollection<Message> ReadAllPopularMessages(int minPopularity, int pageNumber, int pageSize)
  23. {
  24.     return dbContext.Messages
  25.                     .Include(x => x.Author)
  26.                     .OrderDescending(x => x.Popularity)
  27.                     .Skip(pageSize * (pageNumber - 1))
  28.                     .Take(pageSize)
  29.                     .ToArray();
  30. }
  31.    
  32. messageRepository.Where(x=>x.Data >= minDate && x.Date <= maxDate)
  33.     .Skip(10).Take(5).Select( x => new { .... })
RAW Paste Data
Top