public static List<int> GetStudentGroups() { StudentsDataClassesDataContext dc = new StudentsDataClassesDataContext(); var queryResult = (from Students in dc.GetTable<Student>() select Students.Group).Distinct().ToList<int>(); return queryResult; }
//returns the information for a student with Faknum; else null; public static Student GetStudentDataByUser(string faknum) { StudentsDataClassesDataContext dc = new StudentsDataClassesDataContext(); var queryResult = (from Students in dc.GetTable<Student>() where (Students.FakNumber == faknum) select Students).ToArray<Student>(); if (queryResult.Count<Student>() > 0) { return queryResult[0]; } return null; }
public static bool InsertStudent(Student s) { StudentsDataClassesDataContext dc = new StudentsDataClassesDataContext(); try { dc.AddNewStudent(s.FirstName, s.SecondName, s.LastName, s.Faculty, s.Specialty, s.OKS, s.StudentStatus, s.FakNumber, s.Course, s.Potok, s.Group); dc.SubmitChanges(); } catch (Exception) { return false; } return true; }