Exemplo n.º 1
0
        public static void UpdateConfiguration(HttpConfiguration configuration)
        {
            var controllers = new[]
            {
                typeof(CustomersController), typeof(OrdersController), typeof(PeopleController),
                typeof(CompaniesController), typeof(MetadataController)
            };

            TestAssemblyResolver resolver = new TestAssemblyResolver(new TypesInjectionAssembly(controllers));

            configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            configuration.Services.Replace(typeof(IAssembliesResolver), resolver);

            IEdmModel model = AlternateKeysEdmModel.GetEdmModel();

            configuration.Routes.Clear();

            configuration.Count().Filter().OrderBy().Expand().MaxTop(null);

            configuration.MapODataServiceRoute("odata", "odata",
                                               builder =>
                                               builder.AddService(ServiceLifetime.Singleton, sp => model)
                                               .AddService <IEnumerable <IODataRoutingConvention> >(ServiceLifetime.Singleton, sp =>
                                                                                                    ODataRoutingConventions.CreateDefaultWithAttributeRouting("odata", configuration))
                                               .AddService <ODataUriResolver>(ServiceLifetime.Singleton, sp => new AlternateKeysODataUriResolver(model)));

            configuration.EnsureInitialized();
        }
Exemplo n.º 2
0
        public static void UpdateConfiguration(HttpConfiguration configuration)
        {
            var controllers = new[]
            {
                typeof(CustomersController), typeof(OrdersController), typeof(PeopleController),
                typeof(CompaniesController), typeof(MetadataController)
            };

            TestAssemblyResolver resolver = new TestAssemblyResolver(new TypesInjectionAssembly(controllers));

            configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            configuration.Services.Replace(typeof(IAssembliesResolver), resolver);

            configuration.EnableAlternateKeys(true);

            configuration.Routes.Clear();
            IEdmModel model = AlternateKeysEdmModel.GetEdmModel();

            configuration.MapODataServiceRoute("odata", "odata", model: AlternateKeysEdmModel.GetEdmModel());

            var conventions = ODataRoutingConventions.CreateDefault();

            configuration.MapODataServiceRoute("odata1", "convention", model, new DefaultODataPathHandler(), conventions);

            configuration.EnsureInitialized();
        }
Exemplo n.º 3
0
        static AlternateKeysDataSource()
        {
            IEdmModel model = AlternateKeysEdmModel.GetEdmModel();

            BuildCustomers(model);

            BuildOrderss(model);

            BuildPeople(model);

            BuildCompanies(model);
        }