// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseSession(); var routeBuilder = new Microsoft.AspNetCore.Routing.RouteBuilder(app); var db = app.ApplicationServices.CreateScope().ServiceProvider.GetService <SaiMatrimonyDb>(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public static ODataQueryOptions CreateOptionsFromQueryString(this ODataQueryContext context, IDictionary <string, string> queryString) { var collection = new ServiceCollection(); collection.AddOData(); var provider = collection.BuildServiceProvider(); var appBuilder = new ApplicationBuilder(provider); var routeBuilder = new Microsoft.AspNetCore.Routing.RouteBuilder(appBuilder); routeBuilder.EnableDependencyInjection(); routeBuilder.Count().Filter().OrderBy().Expand().Select().MaxTop(1000); //Create request var url = "http://autoPocoInternalOdata.com/site?"; foreach (var param in queryString) { url += param.Key + "=" + param.Value + "&"; } url = url.Trim('?').Trim('&'); var uri = new Uri(url); var httpContext = new DefaultHttpContext { RequestServices = provider }; httpContext.Request.Method = "GET"; httpContext.Request.Host = new HostString(uri.Host); httpContext.Request.Scheme = uri.Scheme; httpContext.Request.Path = uri.LocalPath; httpContext.Request.QueryString = new QueryString(uri.Query); return(new ODataQueryOptions(context, httpContext.Request)); }