I have an OData endpoint in my .NET Core API:
[EnableQuery]
[ODataRoute]
[HttpGet]
public IQueryable<MerchantDto> GetAll()
{
return _context
.Merchants
.Where(x => !x.IsDeleted)
.ProjectTo<MerchantDto>(_mapper.ConfigurationProvider);
}
It generates an SQL without LIMIT
statement (postgres db) and this warning appears:
The LINQ expression 'Take(__TypedProperty_1)' could not be translated and will be evaluated locally.
How can I make this query to DB to include the OData $top
? It is always getting the whole table records first.
I had a wrong object mapping configuration that caused that problem.