Пример #1
0
        public static string GetConnectionString(string name = null)
        {
            var conn = ConnectionStringConfigurator.GetValueOrDefault(name, "");

            if (string.IsNullOrWhiteSpace(conn))
            {
                throw new HBDataException("ConnectionString not defined.");
            }

            return(conn);
        }
Пример #2
0
        public static string GetValueOrDefault(string name, string defaultValue)
        {
            string conn = null;

            var configurator = new ConnectionStringConfigurator().GetCurrent();

            if (configurator != null)
            {
                conn = configurator[name]?.ConnectionString;
            }

            if (conn == null)
            {
                conn = ConfigurationManager.ConnectionStrings[name]?.ConnectionString;
            }

            return(conn ?? defaultValue);
        }