public Alumnos Eliminar() { var alumno = new Alumnos(); try { using (var ctx = new TestContext()) { ctx.Entry(this).State = EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception e) { e.ToString(); throw; } return(alumno); }
//public Alumnos Obtener(int id) //{ // var alumno = new Alumnos(); // try // { // using (var context = new BaseDeDatosContext()) // { // alumno = context.Alumnos // .Include("Ciudades") // .Where(x => x.Alumno_Id == id) // .Single(); // } // } // catch (Exception e) // { // throw new Exception(e.Message); // } // return alumno; //} public Alumnos Obtener(int id) { var alumno = new Alumnos(); try { using (var context = new BaseDeDatosContext()) { alumno = context.Alumnos .Include("Ciudades").Include("Cursos") .Where(x => x.Alumno_Id == id) .Single(); } } catch (Exception e) { throw new Exception(e.Message); } return(alumno); }
public Alumnos Obtener(int id) { var alumno = new Alumnos(); try { using (var ctx = new TestContext()) { alumno = ctx.Alumnos.Include("AlumnoCurso") .Include("AlumnoCurso.Curso") .Where(x => x.idAlumno == id) .SingleOrDefault(); } } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } return(alumno); }