示例#1
0
        protected override void UpdateConfiguration(WebRouteConfiguration configuration)
        {
            var controllers = new[] { typeof(EmployeesController), typeof(MetadataController) };

            configuration.AddControllers(controllers);

            configuration.Routes.Clear();

            IEdmModel edmModel = UnBoundFunctionEdmModel.GetEdmModel(configuration);
            DefaultODataPathHandler pathHandler = new DefaultODataPathHandler();

            // only with attribute routing & metadata routing convention
            IList <IODataRoutingConvention> routingConventions = new List <IODataRoutingConvention>
            {
                configuration.CreateAttributeRoutingConvention(),
                new MetadataRoutingConvention()
            };

            configuration.Count().Filter().OrderBy().Expand().MaxTop(null);
            configuration.MapODataServiceRoute("AttributeRouting", "AttributeRouting", edmModel, pathHandler, routingConventions);

            // only with convention routing
            configuration.MapODataServiceRoute("ConventionRouting", "ConventionRouting", edmModel, pathHandler, ODataRoutingConventions.CreateDefault());
            configuration.EnsureInitialized();
        }