public void Dispose() { if (this.mainCtx != null) { this.mainCtx.Dispose(); this.mainCtx = null; } if (this.levelsCtx != null) { this.levelsCtx.Dispose(); this.levelsCtx = null; } }
public void Attach(String path, AttachType type) { if (type == AttachType.Main) { try { this.mainCtx = new MainContext(this.BuildConnection(path)); this.ValidateDbSchema(this.mainCtx.Database, this.mainDbSchema); } catch { if (this.mainCtx != null) { this.mainCtx.Dispose(); this.mainCtx = null; } throw; } } else if (type == AttachType.Levels) { try { this.levelsCtx = new LevelsContext(this.BuildConnection(path)); this.ValidateDbSchema(this.levelsCtx.Database, this.levelDbSchema); } catch { if (this.levelsCtx != null) { this.levelsCtx.Dispose(); this.levelsCtx = null; } throw; } } }