public async Task<PagedResult<DocumentsVm>> GetAllByFaculty(GetDocumentsPagingRequest request) { var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier)?.Value.ToString(); var query = from d in _context.Documents join u in _context.Users on d.UserID equals u.Id join p in _context.Positions on u.Id equals p.UserID where d.UserID.ToString() == userId select new { d, u,p }; if (request.DocumentId.HasValue && request.DocumentId.Value > 0) { query = query.Where(c => c.u.UserName == request.UserName); } int TotalRow = await query.CountAsync(); var data = await query.Skip((request.PageIndex - 1) * request.PageSize) .Take(request.PageSize) .Select(x => new DocumentsVm() { ID = x.d.ID, UserID = x.u.Id, UserName = x.u.UserName, Caption = x.d.Caption, FacultyID = x.d.FacultyOfDocumentID, MagazineID = x.d.MagazineID, CreateOn = x.d.CreateOn.Date }).ToListAsync(); var pagedResult = new PagedResult<DocumentsVm>() { TotalRecord = TotalRow, Items = data }; return pagedResult; }
var query = from d in _context.Documents join u in _context.Users on d.UserID equals u.Id join p in _context.Positions on u.Id equals p.UserID where d.UserID.ToString() == userId select new { d, u,p };
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)