Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can we read app setting value from web.config in lightswitch desktop application
  2. public class UserConfiguration
  3. {
  4.     [Key]
  5.     public string ConfigKey { get; set; }
  6.     public string ConfigValue { get; set; }
  7.  
  8.  
  9.     public List<UserConfiguration> GetUserConfigurations()
  10.     {
  11.         return _getUserConfigurations();
  12.     }
  13.  
  14.     private List<UserConfiguration> _getUserConfigurations()
  15.     {
  16.         var listOfConfigs = new List<UserConfiguration>();
  17.         var allConfigs = ConfigurationManager.AppSettings;
  18.  
  19.         for (int i = 0; i < allConfigs.Count; i++)
  20.         {
  21.             var userConfig = new UserConfiguration();
  22.             userConfig.ConfigKey = allConfigs.GetKey(i);
  23.             userConfig.ConfigValue = allConfigs[i];
  24.             listOfConfigs.Add(userConfig);
  25.         }
  26.         return listOfConfigs;
  27.     }
  28. }
  29.        
  30. [Query(IsDefault = true)]
  31.     public IQueryable<UserConfiguration> GetUserConfigurations()
  32.     {
  33.         var userConfings = new UserConfiguration();
  34.         return userConfings.GetUserConfigurations().AsQueryable();
  35.     }