예제 #1
0
 /// <summary>
 /// Obtains a setting from the database.
 /// </summary>
 /// <param name="settingName">The name of the setting to retrieve.</param>
 /// <returns>A Settings object corresponding to settingName. If the setting is not found, null.</returns>
 public static Settings GetSetting(string settingName)
 {
     using (BotDBContext dbContext = DatabaseManager.OpenContext())
     {
         return(dbContext.SettingCollection.FirstOrDefault((set) => set.Key == settingName));
     }
 }
예제 #2
0
 /// <summary>
 /// Obtains a setting from the database with an opened context.
 /// </summary>
 /// <param name="settingName">The name of the setting to retrieve.</param>
 /// <param name="context">The open database context.</param>
 /// <returns>A Settings object corresponding to settingName. If the setting is not found, null.</returns>
 public static Settings GetSettingNoOpen(string settingName, BotDBContext context)
 {
     return(context.SettingCollection.FirstOrDefault((set) => set.Key == settingName));
 }