Exemple #1
0
        private IDictionary <string, string> Initialize(ApplicationSettingsContext dbContext)
        {
            foreach (var item in _initialSettings)
            {
                dbContext.Settings.Add(new ApplicationSetting(item.Key, item.Value));
            }

            return(_initialSettings.ToDictionary(it => it.Key, it => it.Value, StringComparer.OrdinalIgnoreCase));
        }
Exemple #2
0
        public override void Load()
        {
            var builder = new DbContextOptionsBuilder <ApplicationSettingsContext>();

            _setup(builder);
            using (ApplicationSettingsContext dbContext = new ApplicationSettingsContext(builder.Options))
            {
                dbContext.Database.EnsureCreated();
                Data = dbContext.Settings.Any()
                    ? dbContext.Settings.ToDictionary(it => it.Key, it => it.Value, StringComparer.OrdinalIgnoreCase)
                    : Initialize(dbContext);
            }
        }