Hi All,
I designed 3 tire layered structure for ASP.Net Core web application, and used EF Core for Data interaction, how to get applicationsetting.json values in Business and data access layer.
Need to access couple of values come from setting.json it mostly DB connection string, resource path, some other constant value.
{"Logging": {"IncludeScopes": false,"LogLevel": {"Default": "Warning" } },"DemoAppSetting": {"ApplicationTitle": "Demo App","ConnectionString": "Server= ---------","RowCount": 1000 } }
public class DemoAppSetting { public string ConnectionString { get; set; } public string ApplicationTitle { get; set; } public int RowCount{ get; set; } }
services.Configure<DemoAppSetting>(Configuration.GetSection("DemoAppSetting"));
public HomeController(IOptions<DemoAppSetting> demoAppSetting) { // demoAppSetting, it holds all value what I have in applicationsetting.jon }
for now I just pass demoAppSetting value to business, data access layer, there is any other way to get the applicationsetting.jon in db, Business layer?
thanks