Exemple #1
0
        /// <summary>
        ///   Initialisiert den Context neu
        /// </summary>
        /// <returns>Initialisierter Db Context</returns>
        public DbContext ReinitializeContext()
        {
            if (this._dataContext != null)
            {
                this._dataContext.Dispose();
            }

            this._dataContext = null;

            return this.GetContext();
        }
Exemple #2
0
 /// <summary>
 ///   Löscht die Datenbank
 /// </summary>
 public void CleanUpDatabase()
 {
     try
     {
         using (var dataContext = new BookContext())
         {
             dataContext.Database.Delete();
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemple #3
0
 /// <summary>
 ///   Gibt den Context zurück. Sofern noch nicht Initialisiert,
 ///   wird dieser erstellt.
 /// </summary>
 /// <returns>
 ///   Db Context
 /// </returns>
 public DbContext GetContext()
 {
     return this._dataContext ?? (this._dataContext = new BookContext());
 }