static void Main(string[] args) { //IConfigurationBuilder builder = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); //IConfigurationRoot configuration = builder.Build(); //string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); ICountryDAO countryDAO = new CountrySqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); ILanguageDAO languageDAO = new LanguageSqlDAO(@"Server=.\SQLEXPRESS;Database=World;Trusted_Connection=True;"); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("NEWDB"); ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { // Use this as is, it will allow you access to the data in appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); // Replace world with the key name used for your connection string in the appsettings.json file string connectionString = configuration.GetConnectionString("World"); ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = null; ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { // The code in the region reads "appsettings" so that the connection string can: // 1) be in one place in the code // 2) can be modified in the bin/debug.netcoreapp2.1 folder without having to // change and recompile the program #region Get Configuration String IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("World"); #endregion ICityDAO cityDAO = new CitySqlDAO(connectionString); ICountryDAO countryDAO = new CountrySqlDAO(connectionString); ILanguageDAO languageDAO = new LanguageSqlDAO(connectionString); WorldGeographyCLI cli = new WorldGeographyCLI(cityDAO, countryDAO, languageDAO); cli.RunCLI(); }
static void Main(string[] args) { WorldGeographyCLI cli = new WorldGeographyCLI(); cli.RunCLI(); }