public List <Alumno> GetAll() { List <Alumno> getRegs = new List <Alumno>(); try { using (var ctx = new DBCursoContext()) { getRegs = ctx.Alumno.ToList(); } } catch (Exception e) { throw e; } return(getRegs); }
public void Delected() { try { using (var ctx = new DBCursoContext()) { if (this.IdAlumno > 0) { ctx.Entry(this).State = EntityState.Deleted; } ctx.SaveChanges(); } } catch (Exception e) { throw; } }
public Alumno GetById(int id) { Alumno alum = new Alumno(); try { using (var ctx = new DBCursoContext()) { alum = ctx.Alumno.Include("AlumnoCurso") .Include("AlumnoCurso.Cuso") .Where(x => x.IdAlumno == id).SingleOrDefault(); } } catch (Exception e) { throw e; } return(alum); }
public void Salve() { try { using (var ctx = new DBCursoContext()) { if (this.IdAlumno > 0) { ctx.Entry(this).State = EntityState.Modified; } else { ctx.Entry(this).State = EntityState.Added; } ctx.SaveChanges(); } } catch (Exception e) { throw e; } }