Ejemplo n.º 1
0
 public List <Student> GetStudentByTeacherId(int teacherId)
 {
     using FineArtsContext context = new FineArtsContext();
     //return context.Students.Where(t => t.TeacherId == teacherId).ToList();
     //declarative using linQ
     return((from s in context.Students
             where s.TeacherId == teacherId
             select s).ToList());
 }
Ejemplo n.º 2
0
        public bool HasTeaches()
        {
            //tradicional way
            //FineArtsContext context = new FineArtsContext();
            //bool result = context.Teachers.Any();
            //context.Dispose();

            //way with full using declaration
            //bool result;
            //using (FineArtsContext context = new FineArtsContext())
            //{
            //    result = context.Teachers.Any();
            //}
            //return result;

            //new short way
            using FineArtsContext context = new FineArtsContext();
            return(context.Teachers.Any());
        }
Ejemplo n.º 3
0
 public bool AddTeachers(Teacher[] teachers)
 {
     using FineArtsContext context = new FineArtsContext();
     context.Teachers.AddRange(teachers);
     return(context.SaveChanges() > 0);
 }
Ejemplo n.º 4
0
 public List <Teacher> GetTeachers()
 {
     using FineArtsContext context = new FineArtsContext();
     return(context.Teachers.ToList());
 }