public static string GetConnectionString() { string SQLInstance = GlobalAsp.GetDataSource(); string user = SQLDataSource.GetUserDB(); string pwd = SQLDataSource.GetPwdDB(); string ConnectionString = string.Format("data source={0};initial catalog=SIPD01DM;user id={1};password={2};Asynchronous Processing=true", SQLInstance, user, pwd); return(ConnectionString); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } //跨域 app.UseCors("cors"); app.UseHttpsRedirection(); app.UseMvc(routeBuilder => { routeBuilder.CustomMapODataServiceRoute("odata", "odata/{dataSource}"); string connectStr = "Server=.;Initial Catalog=DynamicOData.Core.Demo;Persist Security Info=False;User ID=sa;Password=Password01!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"; var sqlSource = new SQLDataSource(Constants.SqlServerDataSource, connectStr); DynamicOData.AddDataSource(sqlSource); }); }