public static void AddNewRecord() { using (testEntities contex = new testEntities()) { try { contex.Courses.Add(new Courses("Test",5.0, "1.0",DateTime.Now)); contex.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.InnerException.Message); } } }
public static void FindETCS() { using (testEntities contex = new testEntities()) { try { //Define a key for the entity we are looking for. var courses = contex.Courses.Where(p => p.ECTS == (decimal) 5.0); PrintCoures(courses ); } catch (Exception e) { Console.WriteLine(e.InnerException.Message); } } }
public static void RemoveRecord() { using (testEntities contex = new testEntities()) { try { //Define a key for the entity we are looking for. var coursesToDelete = contex.Courses.Where(p => p.Cid == 1); if (coursesToDelete != null) { contex.Courses.RemoveRange(coursesToDelete); contex.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e.InnerException.Message); } } }