Esempio n. 1
0
 public List <TestEntity> GetAll()
 {
     using (var context = new AppContext())
     {
         var result = context.TestEntities.ToList();
         return(result);
     }
 }
Esempio n. 2
0
        public List <Department> GetAll()
        {
            List <Department> dbDepartments;

            try
            {
                using (var context = new AppContext())
                {
                    dbDepartments = context.Departments.ToList();
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                throw ex;
            }
            return(dbDepartments);
        }
Esempio n. 3
0
        public TestEntity Create(TestEntity testEntity)
        {
            TestEntity dbTestEntity;

            try
            {
                using (var context = new AppContext())
                {
                    //Create a new entry in table, and get the new object
                    dbTestEntity = context.TestEntities.Add(testEntity);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //todo exeption handling
                throw ex;
            }

            return(dbTestEntity);
        }
Esempio n. 4
0
 public DepartmentRepository(AppContext context)
 {
     _context = context;
 }