Ejemplo n.º 1
0
        public void Can_attach()
        {
            Customer customer = null;
            var testData = new EFTestData(Context);
            testData.Batch(x => customer = x.CreateCustomer());
            Context.Detach(customer);
            Context.Dispose();

            using (var scope = new UnitOfWorkScope())
            {
                var repository = new EFRepository<Customer>();
                repository.Attach(customer);
                customer.FirstName = "Changed";
                scope.Commit();
            }

            Context = new CodeOnlyContext("SandboxCodeOnly").Context;
            testData = new EFTestData(Context);
            customer = testData.Get<Customer>(x => x.CustomerID == customer.CustomerID);
            Assert.That(customer.FirstName, Is.EqualTo("Changed"));
        }
Ejemplo n.º 2
0
        public void Can_attach()
        {
            Customer customer = null;
            var      testData = new EFTestData(Context);

            testData.Batch(x => customer = x.CreateCustomer());
            Context.Detach(customer);
            Context.Dispose();

            using (var scope = new UnitOfWorkScope())
            {
                var repository = new EFRepository <Customer>();
                repository.Attach(customer);
                customer.FirstName = "Changed";
                scope.Commit();
            }

            Context  = new CodeOnlyContext("SandboxCodeOnly").Context;
            testData = new EFTestData(Context);
            customer = testData.Get <Customer>(x => x.CustomerID == customer.CustomerID);
            Assert.That(customer.FirstName, Is.EqualTo("Changed"));
        }