public void Can_attach() { Customer customer = null; var testData = new EFTestData(Context); testData.Batch(x => customer = x.CreateCustomer()); testData.Context.Detach(customer); Context.Dispose(); using (var scope = new UnitOfWorkScope()) { var repository = new EFRepository<Customer,int>(); repository.Attach(customer); customer.FirstName = "Changed"; scope.Commit(); } testData = new EFTestData(Context); customer = testData.Get<Customer>(x => x.CustomerID == customer.CustomerID); Assert.AreEqual(customer.FirstName, "Changed"); }
public void Can_attach_modified_entity() { Customer customer = null; var testData = new EFTestData(Context); testData.Batch(x => customer = x.CreateCustomer()); Context.Detach(customer); Context.Dispose(); using (var scope = new UnitOfWorkScope()) { customer.LastName = "Changed"; var repository = new EFRepository<Customer>(); repository.Attach(customer); scope.Commit(); } Context = new PocoContext(ConnectionString); testData = new EFTestData(Context); customer = testData.Get<Customer>(x => x.CustomerID == customer.CustomerID); Assert.That(customer.LastName, Is.EqualTo("Changed")); }
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")); }
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")); }
public void Can_attach_modified_entity() { Customer customer = null; var testData = new EFTestData(Context); testData.Batch(x => customer = x.CreateCustomer()); Context.Detach(customer); Context.Dispose(); using (var scope = new UnitOfWorkScope()) { customer.LastName = "Changed"; var repository = new EFRepository <Customer>(); repository.Attach(customer); scope.Commit(); } Context = new PocoContext(ConnectionString); testData = new EFTestData(Context); customer = testData.Get <Customer>(x => x.CustomerID == customer.CustomerID); Assert.That(customer.LastName, Is.EqualTo("Changed")); }