public virtual string GetConfigSetting(string key) { var environmentKey = _appSettingsProvider.GetSetting(Constants.AppSettings.EnvironmentKey); if (String.IsNullOrEmpty(environmentKey)) { throw new ArgumentOutOfRangeException(Constants.AppSettings.EnvironmentKey); } var record = _inventoryContext.ConfigurationValue.SingleOrDefault(c => c.ConfigKey == key && (c.AppEnvironment.ReferenceKey == environmentKey)); if (record != null) { return(record.ConfigValue); } else { //throw new ArgumentOutOfRangeException("ConfigKey:" + key); throw new ArgumentException("ConfigKey:" + key); } }