Example #1
0
 public static void Register()
 {
     try
     {
         var builder       = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
         var config        = builder.Build();
         var appConnection = new SqlConnection(config.GetSection("ConnectionStrings").GetSection("AppConnection").Value);
         if (appConnection != null)
         {
             string appStringConnection = appConnection.ConnectionString;
             DataAccessEnterprise.Initialize(appStringConnection);
         }
     }
     catch (Exception e)
     { string _mensaje = e.Message; }
 }
Example #2
0
 public static void Register()
 {
     try
     {
         var StringConnectionPath = HttpContext.Current.Server.MapPath("~/Web.config");
         var StringConnectionMap  = new ExeConfigurationFileMap()
         {
             ExeConfigFilename = StringConnectionPath
         };
         var config        = ConfigurationManager.OpenMappedExeConfiguration(StringConnectionMap, ConfigurationUserLevel.None);
         var appConnection = config.ConnectionStrings.ConnectionStrings["AppConnection"];
         if (appConnection != null)
         {
             string appStringConnection = appConnection.ConnectionString;
             DataAccessEnterprise.Initialize(appStringConnection);
         }
     }
     catch (Exception e)
     { string _mensaje = e.Message; }
 }