Exemplo n.º 1
0
        private ODataQueryOptions <TModel> GetODataQueryOptions <TModel>(string query) where TModel : class
        {
            if (_oDataQueryOptions == null)
            {
                _oDataQueryOptions = ODataHelpers.GetODataQueryOptions <TModel>
                                     (
                    query,
                    serviceProvider
                                     );
            }

            return((ODataQueryOptions <TModel>)_oDataQueryOptions);
        }
Exemplo n.º 2
0
        private ODataQueryOptions <TModel> GetODataQueryOptions <TModel>(string query) where TModel : class
        {
            if (_oDataQueryOptions == null)
            {
                _oDataQueryOptions = ODataHelpers.GetODataQueryOptions <TModel>
                                     (
                    query,
                    serviceProvider,
                    serviceProvider.GetRequiredService <IRouteBuilder>()
                                     );
            }

            return((ODataQueryOptions <TModel>)_oDataQueryOptions);
        }
Exemplo n.º 3
0
        public async void BuildingExpandBuilderTenantExpandCityFilterOnNestedNestedPropertyWithCount()
        {
            string query = "/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$filter=Builder/City/Name eq 'Leeds'&$count=true";
            ODataQueryOptions <CoreBuilding> options = ODataHelpers.GetODataQueryOptions <CoreBuilding>
                                                       (
                query,
                serviceProvider
                                                       );

            Test(Get <CoreBuilding, TBuilding>(query, options));
            Test(await GetAsync <CoreBuilding, TBuilding>(query, options));

            void Test(ICollection <CoreBuilding> collection)
            {
                Assert.Equal(2, options.Request.ODataFeature().TotalCount);
                Assert.Equal(2, collection.Count);
                Assert.Equal("Leeds", collection.First().Builder.City.Name);
            }
        }
Exemplo n.º 4
0
        public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Take1NoCount()
        {
            string query = "/corebuilding?$skip=4&$top=1&$expand=Builder($expand=City),Tenant&$orderby=Name desc,Identity";
            ODataQueryOptions <CoreBuilding> options = ODataHelpers.GetODataQueryOptions <CoreBuilding>
                                                       (
                query,
                serviceProvider
                                                       );

            Test(Get <CoreBuilding, TBuilding>(query, options));
            Test(await GetAsync <CoreBuilding, TBuilding>(query, options));

            void Test(ICollection <CoreBuilding> collection)
            {
                Assert.Null(options.Request.ODataFeature().TotalCount);
                Assert.Equal(1, collection.Count);
                Assert.Equal("London", collection.First().Builder.City.Name);
                Assert.Equal("One L1", collection.First().Name);
            }
        }