예제 #1
0
 /// <summary>
 /// Diese Methode liefert die höchste installierte DBVersion
 /// </summary>
 /// <returns></returns>
 public DBVersion HighestVersion()
 {
     using (var ctx = new VersionContext(this.NameOrConnectionString))
     {
         return ctx.DBVersions.OrderByDescending(e => e.PrimaryVersion).OrderByDescending(e => e.SecondaryVersion).FirstOrDefault();
     }
 }
예제 #2
0
 /// <summary>
 /// Diesst die Konfiguration mit dem angegebenen Pfad
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public DBVersion GetEntityById(long id)
 {
     using (var ctx = new VersionContext(this.NameOrConnectionString))
     {
         return ctx.DBVersions.Where(e => e.Id == id).FirstOrDefault();
     }
 }
예제 #3
0
 /// <summary>
 /// Diese Methode liefert die letzte ausgeführte SQL-Querries
 /// </summary>
 /// <returns></returns>
 public DBVersion LastExecuted()
 {
     using (var ctx = new VersionContext(this.NameOrConnectionString))
     {
         return ctx.DBVersions.OrderByDescending(e => e.Installdate).FirstOrDefault();
     }
 }
예제 #4
0
 /// <summary>
 /// Liefert alle Gruppen nach den Campagnenname sortiert
 /// </summary>
 /// <returns></returns>
 public List<DBVersion> GetAllEntities()
 {
     using (var ctx = new VersionContext(this.NameOrConnectionString))
     {
         return ctx.DBVersions.ToList();
     }
 }
예제 #5
0
        /// <summary>
        /// Diese Methode speichert eine DBVersion-Entität
        /// </summary>
        /// <param name="entity">
        /// Die zu speichernde Entität
        /// </param>
        /// <returns>
        /// Die gespeicherte Entität
        /// </returns>
        public DBVersion SaveUpdateEntity(DBVersion entity)
        {
            using (var context = new VersionContext(this.NameOrConnectionString))
            {
                if (context.GetValidationErrors() != null && context.GetValidationErrors().Count() > 0)
                {
                    //TODO: Erweitern um den Fehler
                    throw new ValidationException();
                }

                if (GetEntityById(entity.Id) == null)
                {
                    context.DBVersions.Add(entity);
                }
                else
                {
                    context.DBVersions.Attach(entity);
                    context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                }
                context.SaveChanges();
                return entity;
            }
        }