0

i have a controller 1 inherited form ApiController returning IQueryable of some entity.

i have another controller 2 returning same thing but inherited form ODataController and oData route configurations like this

            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
        builder.EntitySet<StoreCommand>("StoreCommandsTest");
        config.Routes.MapODataServiceRoute(routeName: "OData", routePrefix: "api", model: builder.GetEdmModel());
        config.AddODataQueryFilter();

when i try to run http://localhost:xxxx/api/Controller1?$inlinecount=allpages&$top=0 i get blank json object result

when i try to run http://localhost:xxxx/api/Controller2?$inlinecount=allpages&$top=0 i get proper results with odata.count = 100

my question is what is wrong in the case of controller 1 ?

eventually i am trying to get just only the count.

Raas Masood
  • 1,475
  • 3
  • 23
  • 61

1 Answers1

0

Those query options should work with ApiController, but you should add EnableQuery attribute in controller's method.

http://localhost:xxxx/api/Customers/$count to get just only the count.

Fan Ouyang
  • 2,132
  • 1
  • 11
  • 13