public static Setting GetSystemSetting(string key) { if (_SystemSettings == null) { CriticalResultsTransporterEntities context = new CriticalResultsTransporterEntities(); var query = from settings in context.SettingEntitySet where settings.Owner == SETTINGS_SYSTEM select settings; _SystemSettings = query.ToDictionary<SettingEntity, String, Setting>(x => x.EntryKey, x => new Setting(x)); } return _SystemSettings[key]; }
private static void ExpireAllTokensForUser(string userName) { CriticalResultsTransporterEntities context = new CriticalResultsTransporterEntities(); DateTime deadTokenTime = DateTime.Now - GetTokenLifespan(); var query = from tokens in context.TokenEntitySet.Include("User") where tokens.User.UserName == userName where tokens.UpdatedTime < deadTokenTime select tokens; TokenEntity[] tokenArray = query.ToArray(); foreach (TokenEntity token in tokenArray) { context.DeleteObject(token); } try { context.SaveChanges(); } catch { } }
public CriticalResultsEntityManager() { _ObjectContext = new CriticalResultsTransporterEntities(); }