SHARE
TWEET

Linq

fight90 Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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),//Math.Floor((((decimal)p.Pictures.Count()-1) / ServicesDataConstraints.EditProfilePictureServicePageSize)),
  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();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top