RESTier icon indicating copy to clipboard operation
RESTier copied to clipboard

ModelBuilder not respecting EntitySet<T>().EntityType.Page()

Open robertmclaws opened this issue 8 years ago • 3 comments

WebAPI OData 7.0 allows you to control paging on a per-entity basis through the .Page() fluent configuration function on ODataConventionModelBuilder.

RESTier does not appear to honor this setting.

Assemblies affected

RESTier 1.0.0-Beta1

Reproduce steps

    public partial class TestApi : EntityFrameworkApi<TestContext>
    {

        public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
        {
            return EntityFrameworkApi<TestContext>.ConfigureApi(apiType, services)
                .AddService<IModelBuilder, TestModelBuilder>();
        }

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceProvider"></param>
        public TestApi(IServiceProvider serviceProvider) : base(serviceProvider)
        {
        }

        #endregion

    }

    internal class TestModelBuilder : IModelBuilder
    {
        public Task<IEdmModel> GetModelAsync(ModelContext context, CancellationToken cancellationToken)
        {
            var modelBuilder = new ODataConventionModelBuilder();

            modelBuilder.EntitySet<Bicycle>("Bicycles")
                .EntityType.HasKey(c => c.Id)
                .Page(250, 50);

            return Task.FromResult(modelBuilder.GetEdmModel());
        }
    }

Expected result

I would expect to only see 50 results in the payload.

Actual result

I see 70,000 results in the payload.

robertmclaws avatar Mar 30 '17 19:03 robertmclaws

Would love to see this fixed.

mikepizzo avatar Jun 10 '17 00:06 mikepizzo

Without making you dig in too deeply, based on what you know @mikepizzo, what would it take to fix this?

robertmclaws avatar Jul 03 '19 19:07 robertmclaws

RESTier is likely not looking at the ModelBuilder when it is calling the execution pipeline. Need to look into how to pull this out of the model builder and reconcile with the MaxTop() method.

robertmclaws avatar Jul 30 '19 16:07 robertmclaws

Tracking through the above-mentioned super-issue.

robertmclaws avatar Dec 05 '23 18:12 robertmclaws