'C# IQueryable - TakeLast(__p_0)' could not be translated Error

My private get all method

    private IQueryable<Category> getAll()
        => _unitOfWork.CategoryRepo
               .GetAll()
               .Include(x => x.CategoryDetails)
               .Include(x => x.Categories)
               .ThenInclude(x => x.CategoryDetails);

This is what i tried:

await getAll().OrderBy(x => x.Id).TakeLast(1000).ToListAsync()

Error (Same error in .net 6 and 3.1):

The LINQ expression 'DbSet<Category>()
    .Include(x => x.CategoryDetails)
    .Include(x => x.Categories)
    .ThenInclude(x => x.CategoryDetails)
    .OrderBy(x => x.Id)
    .TakeLast(__p_0)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source