public void TestODataRequestHelper_ModifyResponse() { var data = File.ReadAllText(Directory.GetCurrentDirectory() + @"/Data/sampledata.json"); data = data.Replace("//Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.\r\n", string.Empty).Trim(); var odataRequestHelper = new ODataRequestHelper(); var resp = odataRequestHelper.ModifyResponse(data, true, true, "Test"); Assert.DoesNotContain("@odata.type", resp); Assert.Contains("Test", resp); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.EnableDependencyInjection(); endpoints.Filter().Expand().Select().OrderBy().MaxTop(null).Count(); endpoints.MapODataRoute("odata", "odata/entities/{entityname}", containerBuilder => { containerBuilder.AddService(Microsoft.OData.ServiceLifetime.Scoped, typeof(IEdmModel), sp => { var serviceScope = sp.GetRequiredService <HttpRequestScope>(); var modelSettingsProvider = app.ApplicationServices.GetService <IODataModelSettingsProvider>(); var odataRequestHelper = new ODataRequestHelper(); return(odataRequestHelper.GetEdmModel(serviceScope.HttpRequest , modelSettingsProvider.GetEdmModelSettingsFromRequest(serviceScope.HttpRequest), "Microsoft.Contoso.Models")); }); containerBuilder.AddService(Microsoft.OData.ServiceLifetime.Scoped, typeof(IEnumerable <IODataRoutingConvention>), sp => { IList <IODataRoutingConvention> routingConventions = ODataRoutingConventions.CreateDefault(); routingConventions.Insert(0, new MatchAllRoutingConvention("MatchAll")); return(routingConventions.ToList().AsEnumerable()); }); }); }); }