how to make odata query directly run on db sql query

55 views
Skip to first unread message

lokanath das

unread,
Aug 10, 2022, 7:17:44 AM8/10/22
to OData Discussion
I am currently developing an Api. Where I have a GET endpoint. where I am using OData Query attribute i.e. [EnableQuery] .

I have added the filter in the Program.cs . Its in .Net 6.


builder.Services.AddControllers(options => { options.Filters.Add(new EnableQueryAttribute() { AllowedQueryOptions = AllowedQueryOptions.All, AllowedOrderByProperties = null, AllowedLogicalOperators = AllowedLogicalOperators.All, }); }).AddOData(o => o.Select().Filter().SetMaxTop(100).OrderBy().Count());


So issue is, while querying to database, Odata filter not getting applied, instead it etch all records then applying the filter. So in the real scenario where there is huge record count its a bottleneck situation. How to implement the filters before hitting to the database? I am using Iqueryable.

What I am missing here?

Reply all
Reply to author
Forward
0 new messages