コード例 #1
0
 /// <summary>
 /// Delete all entries from one entity type
 /// </summary>
 /// <typeparam name="T"></typeparam>
 public void DeleteAllEntries <T>() where T : Entity
 {
     using (MachineModel model = new MachineModel())
     {
         model.Set <T>().RemoveRange(model.Set <T>().ToList());
         model.SaveChanges();
     }
 }
コード例 #2
0
 /// <summary>
 /// Insert a list of entites into the related database table
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="insertObjects"></param>
 public void InsertObjectsIntoDatabase <T>(List <T> insertObjects) where T : Entity
 {
     using (MachineModel model = new MachineModel())
     {
         model.Set <T>().AddRange(insertObjects);
         model.SaveChanges();
     }
 }
コード例 #3
0
        /// <summary>
        /// Get all entries from one entity type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public List <T> GetAllEntries <T>() where T : Entity
        {
            List <T> result = null;

            using (MachineModel model = new MachineModel())
            {
                result = model.Set <T>().ToList();
            }
            return(result);
        }
コード例 #4
0
 /// <summary>
 /// Check if the related entity table contains entries
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public bool CheckIfTableEmpty <T>() where T : Entity
 {
     using (MachineModel model = new MachineModel())
     {
         if (model.Set <T>().FirstOrDefault() != null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }