public IEnumerable <Project> GetProjects() { var project = _projectRepo.Fetch() .Where(n => n.Active) .GroupBy(n => n.Id) .Select(g => g.OrderByDescending(x => x.CreatedAt).FirstOrDefault()) .ToList(); foreach (var Proj in project) { var projectUsers = _projectUsersRepo.Fetch().Where(i => i.ProjectId == Proj.Id).ToList(); foreach (var projUsers in projectUsers) { Proj.Users.Add((ApplicationUser)_userRepo.Fetch().Where(i => i.Id == projUsers.AspNetUsersId).FirstOrDefault()); } } return(project); }