예제 #1
0
        public void Optimisitc_Concurrency_Off_By_Default()
        {
            var db1 = new MovieDataContext();
            var db2 = new MovieDataContext();

            var movie1 = db1.Movies.Single(m => m.Title == "Jurassic Park");
            var movie2 = db2.Movies.Single(m => m.Title == "Jurassic Park");
            movie2.Length += 1;
            db2.SaveChanges();

            movie1.Length += 2;
            db1.SaveChanges();
        }
예제 #2
0
        public void DataContext_Is_A_Unit_Of_Work()
        {
            var db1 = new MovieDataContext();
            var db2 = new MovieDataContext();

            var movie1 = db1.Movies.Single(m => m.Title == "Jurassic Park");
            var movie2 = db2.Movies.Single(m => m.Title == "Jurassic Park");
            movie2.Length += 1;
            db2.SaveChanges();

            movie1 = db1.Movies.Single(m => m.Title == "Jurassic Park");

            Assert.AreNotEqual(movie1.Length, movie2.Length);
        }
예제 #3
0
        public void Can_Reload_an_Entity()
        {
            var db1 = new MovieDataContext();
            var db2 = new MovieDataContext();

            var movie1 = db1.Movies.Single(m => m.Title == "Jurassic Park");
            var movie2 = db2.Movies.Single(m => m.Title == "Jurassic Park");
            movie2.Length += 1;
            db2.SaveChanges();

            db1.Entry(movie1).Reload();

            Assert.AreEqual(movie1.Length, movie2.Length);
        }