I have the following code:
List<int> projectIds=GetProjectsIds();// size is about 100,000 int value.
List<int> userIds=GetUsersIds();// size is about 100,000 int value.
List<int> nextIds=GetNextIds();// size is about 100,000 int value.
var IQueryList= db.Users.Where(obj=> projectIds.any(x=>x==obj.ProjectID)
|| userIds.any(x=>x==obj.UserId)
|| nextIds.any(x=>x==obj.NextId) );
it takes really long time when converting the IQueryable
to List
.
var YearsGroup = IQueryList.GroupBy(x => x.CreatedOn.Year)
.Select(g => g.FirstOrDefault())
.ToList()
.OrderByDescending(x => x.CreatedOn.Year);
// it's taking about 3 seconds to get executed.
How can I solve this issues, is there any other ways that I can apply to my code?