public List <TestEntity> GetAll() { using (var context = new AppContext()) { var result = context.TestEntities.ToList(); return(result); } }
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); }
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); }
public DepartmentRepository(AppContext context) { _context = context; }