刚开始使用.Net Core并将连接字符串信息传递给Context控制台项目.
我有4个项目,使用.Net Core创建.
在MVC项目中,我有Startup.cs文件,我正在阅读appsettings.json文件
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddMvc();
// Add appsettings
services.Configure<AppSettingsConfig>(Configuration.GetSection("AppSettings"));
}
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
if (env.IsDevelopment())
{
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(developerMode: true);
}
Configuration = builder.Build();
}
Run Code Online (Sandbox Code Playgroud)
在我的第4个项目(Data Layer)中,有哪个Console Project并且有以下DBContext类.这个项目没有像我MVC项目那样的Startup.cs.不是由VS 2015默认创建的.
public class MyDWContext : DbContext …Run Code Online (Sandbox Code Playgroud) 我想在javascript中找到舍入的最接近的数字,例如
10 - > 10
11 - > 10
12 - > 10
13 - > 15
16 - > 15
17 - > 15
18 - > 20
19 - > 20
20 - > 20