public void Auto_DetectChanges_for_Entry_can_be_switched_off(bool useGenericOverload) { using (var context = new ButTheHedgehogContext(InMemoryTestHelpers.Instance.CreateServiceProvider())) { context.ChangeTracker.AutoDetectChangesEnabled = false; var entry = context.Attach(new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Cracked Cookies"; Assert.Equal(EntityState.Unchanged, entry.State); if (useGenericOverload) { context.Entry(entry.Entity); } else { context.Entry((object)entry.Entity); } Assert.Equal(EntityState.Unchanged, entry.State); } }
public void Entry_calls_DetectChanges_by_default(bool useGenericOverload) { using (var context = new ButTheHedgehogContext(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var entry = context.Attach( new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Cracked Cookies"; Assert.Equal(EntityState.Unchanged, entry.State); if (useGenericOverload) { context.Entry(entry.Entity); } else { context.Entry((object)entry.Entity); } Assert.Equal(EntityState.Modified, entry.State); } }
public void Auto_DetectChanges_for_Entry_can_be_switched_off(bool useGenericOverload) { using (var context = new ButTheHedgehogContext(TestHelpers.Instance.CreateServiceProvider())) { context.ChangeTracker.AutoDetectChangesEnabled = false; var entry = context.Attach(new Product { Id = 1, Name = "Little Hedgehogs" }, behavior: GraphBehavior.SingleObject); entry.Entity.Name = "Cracked Cookies"; Assert.Equal(EntityState.Unchanged, entry.State); if (useGenericOverload) { context.Entry(entry.Entity); } else { context.Entry((object)entry.Entity); } Assert.Equal(EntityState.Unchanged, entry.State); } }
public void Entry_calls_DetectChanges_by_default(bool useGenericOverload) { using (var context = new ButTheHedgehogContext(TestHelpers.Instance.CreateServiceProvider())) { var entry = context.Attach(new Product { Id = 1, Name = "Little Hedgehogs" }, behavior: GraphBehavior.SingleObject); entry.Entity.Name = "Cracked Cookies"; Assert.Equal(EntityState.Unchanged, entry.State); if (useGenericOverload) { context.Entry(entry.Entity); } else { context.Entry((object)entry.Entity); } Assert.Equal(EntityState.Modified, entry.State); } }