Example #1
0
 public void LikeTest()
 {
     using (var context = new ObjectOrientedDbContext())
     {
         var stds = context.Students.Where(i => EF.Functions.Like(i.StudentSubjects.Single().Student.FirstName, "%" + i.FirstName + "%")).ToList();
     }
 }
Example #2
0
 public void GetStudentWithNavigationPro()
 {
     using (var context = new ObjectOrientedDbContext())
     {
         var st = context.Students
                  .Include(i => i.StudentSubjects.Where(i => i.SubjectId == 1))
                  .ThenInclude(i => i.Subject);
         var str = st.ToQueryString();
         var l   = st.ToList();
     }
 }
Example #3
0
        public void Update()
        {
            using (var context = new ObjectOrientedDbContext())
            {
                var st = context.Students.Single(i => i.Id == 1);
                st.SetFirstName("Mofaggol123");

                context.SaveChanges();

                var st2 = context.Students.Single(i => i.Id == 1);
            }
        }
Example #4
0
        public void Insert()
        {
            using (var context = new ObjectOrientedDbContext())
            {
                var st = new Student(firstName: "Matthias-1", lastName: "Stahl", department: "GroupWare", university: "Quipu");

                context.Students.Add(st);

                context.SaveChanges();

                var st2 = context.Students.Single(i => i.FirstName == "Matthias-1");
            }
        }
Example #5
0
        public void Update2()
        {
            using (var context = new ObjectOrientedDbContext())
            {
                var st = context.Students
                         //.AsNoTracking()
                         .Single(i => i.Id == 1);
                st.SetFirstName("Mofaggol123");

                context.Students.Attach(st);

                context.Entry(st).Property(i => i.LastName).IsModified = true;

                context.SaveChanges();

                var st1 = context.Students.Single(i => i.Id == 1);
            }
        }