Advertisement
fight90

Linq

Jun 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1.  
  2.             var model = await db.Users.Where(u => u.Id == id).Select(p => new ProfilePictureServiceModel
  3.             {
  4.                 Id = p.Pictures
  5.            .Where(pp => pp.isProfilePicture == true)
  6.            .Select(i => i.PictureId).FirstOrDefault(),
  7.  
  8.                 PictureByteArray = p.Pictures
  9.            .Where(pp => pp.isProfilePicture == true)
  10.            .Select(cpp => cpp.PictureByteArray)
  11.            .FirstOrDefault(),
  12.  
  13.                 allPage = (p.Pictures.Count() - 1) % ServicesDataConstraints.EditProfilePictureServicePageSize == 0 ? ((p.Pictures.Count() - 1) / ServicesDataConstraints.EditProfilePictureServicePageSize) : (((p.Pictures.Count() - 1) / ServicesDataConstraints.EditProfilePictureServicePageSize) + 1),
  14.  
  15.                 Pictures = p.Pictures
  16.            .Where(f => f.isProfilePicture == false)
  17.            .OrderByDescending(o => o.PictureId)
  18.            .Skip((page - 1) * ServicesDataConstraints.EditProfilePictureServicePageSize)
  19.            .Take(ServicesDataConstraints.EditProfilePictureServicePageSize)
  20.            .Select(k =>
  21.            new ChildPicturesServiceModel
  22.            {
  23.                PictureByteArray = k.PictureByteArray,
  24.                Id = k.PictureId,
  25.  
  26.            })
  27.            .ToList()
  28.             }).FirstOrDefaultAsync();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement