public void Executing_a_stored_proc_mapped_to_a_function_import_honors_no_tracking_merge_option() { using (var context = new AdvancedPatternsModelFirstContext()) { // Act context.AllOfficesStoredProc(MergeOption.NoTracking).ToList(); // Verify Assert.True(context.ChangeTracker.Entries <OfficeMf>().Count() == 0); } }
public void Executing_a_stored_proc_mapped_to_a_function_import_with_merge_option_overwrite_changes() { using (var context = new AdvancedPatternsModelFirstContext()) { // Arrange var office = context.Offices.Find("1/1221", AdvancedPatternsModelFirstInitializer.KnownBuildingGuid); context.Entry(office).Property("Description").CurrentValue = "Test"; // Act context.AllOfficesStoredProc(MergeOption.OverwriteChanges).ToList(); // Verify Assert.True(context.Entry(office).State == EntityState.Unchanged); Assert.True(context.ChangeTracker.Entries <OfficeMf>().Count() == 4); } }
public void Can_read_entities_from_a_stored_proc_mapped_to_a_function_import_with_merge_option() { using (var context = new AdvancedPatternsModelFirstContext()) { var offices = context.AllOfficesStoredProc(MergeOption.NoTracking).ToList(); Assert.Equal(4, offices.Count); Assert.Equal(0, context.Offices.Local.Count); new List <string> { "1/1221", "1/1223", "2/1458", "2/1789" }.ForEach( n => offices.Where(o => o.Number == n).Single()); } }
public void Can_read_entities_from_a_stored_proc_mapped_to_a_function_import() { using (var context = new AdvancedPatternsModelFirstContext()) { var offices = context.AllOfficesStoredProc().ToList(); Assert.Equal(4, offices.Count); Assert.Equal(4, context.Offices.Local.Count); var officeNumbers = new List <string> { "1/1221", "1/1223", "2/1458", "2/1789" }; foreach (var officeNumber in officeNumbers) { offices.Single(o => o.Number == officeNumber); } } }