none
Is it possible to use $count without OData endpoint? RRS feed

  • Question

  • I have problem with count function in Odata. When I use https://localhost:44327/odata/Customers?$count=true its working correctly but with https://localhost:44327/Customers/Get?$count=true count is ignored.

    Controller :

    [EnableQuery][HttpGet]public IActionResult Get()
    {    return Ok(_context.Customers);}


    Startup.cs :routeBuilder.Select().Filter().Expand().OrderBy().MaxTop(100).Count();
    routeBuilder.EnableDependencyInjection();
    routeBuilder.MapODataServiceRoute("odata", "odata",GetEdmModel());
    
    private static IEdmModel GetEdmModel()
    {    
        ODataModelBuilder builder = new 
        ODataConventionModelBuilder();    
        EntitySetConfiguration<CustomerDto> customers = builder.EntitySet<CustomerDto>("Customers");    
        customers.EntityType.HasKey(entity => entity.Id);  
        EntitySetConfiguration<OrderDto> orders = builder.EntitySet<OrderDto>("Orders");   
        orders.EntityType.Name = "Order";    
        orders.EntityType.Property(p => p.Total).Name = "Check";  
        return builder.GetEdmModel();
    }

    Friday, June 21, 2019 8:13 AM