Esempio n. 1
0
        public void Example12AExplicitLoading()
        {
            var context = new BazaDanych();

            context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

            var student = context.Students.First();

            context.Entry(student).Reference(s => s.Study).Load();
            context.Entry(student).Collection(s => s.StudentSubject).Load();

            int g = 0;
        }
Esempio n. 2
0
        public void Example10UpdatingElement()
        {
            try
            {
                var context = new BazaDanych();
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var stToRemove = new Student
                {
                    IdStudent = 3,
                    FirstName = "ZMIENIONY",
                    LastName  = "ZMIENIONY",
                    IdStudies = 1,
                    Address   = "a"
                };

                context.Students.Attach(stToRemove);
                var entry = context.Entry <Student>(stToRemove);
                entry.State = EntityState.Modified;

                context.SaveChanges();
            }
            catch (DbEntityValidationException exc)
            {
                int g = 0;
            }
        }
Esempio n. 3
0
        public void Example9RemovingElement()
        {
            try
            {
                var context = new BazaDanych();
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var student = new Student
                {
                    IdStudent = 1,
                    LastName  = "Sth"
                };

                context.Students.Attach(student);
                context.Entry <Student>(student).State = EntityState.Modified;
                context.SaveChanges(); //
            }
            catch (Exception exc)
            {
                int g = 0;
            }
        }