1 //--------------------------------------------------------------------- 2 // <copyright file="ExtractedStateEntry.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 // 6 // @owner Microsoft 7 //--------------------------------------------------------------------- 8 9 10 using System.Collections.Generic; 11 using System.Data.Common.CommandTrees; 12 using System.Data.Metadata.Edm; 13 using System.Diagnostics; 14 using System.Linq; 15 namespace System.Data.Mapping.Update.Internal 16 { 17 /// <summary> 18 /// Represents the data contained in a StateEntry using internal data structures 19 /// of the UpdatePipeline. 20 /// </summary> 21 internal struct ExtractedStateEntry 22 { 23 internal readonly EntityState State; 24 internal readonly PropagatorResult Original; 25 internal readonly PropagatorResult Current; 26 internal readonly IEntityStateEntry Source; 27 ExtractedStateEntrySystem.Data.Mapping.Update.Internal.ExtractedStateEntry28 internal ExtractedStateEntry(UpdateTranslator translator, IEntityStateEntry stateEntry) 29 { 30 Debug.Assert(null != stateEntry, "stateEntry must not be null"); 31 this.State = stateEntry.State; 32 this.Source = stateEntry; 33 34 switch (stateEntry.State) 35 { 36 case EntityState.Deleted: 37 this.Original = translator.RecordConverter.ConvertOriginalValuesToPropagatorResult( 38 stateEntry, ModifiedPropertiesBehavior.AllModified); 39 this.Current = null; 40 break; 41 case EntityState.Unchanged: 42 this.Original = translator.RecordConverter.ConvertOriginalValuesToPropagatorResult( 43 stateEntry, ModifiedPropertiesBehavior.NoneModified); 44 this.Current = translator.RecordConverter.ConvertCurrentValuesToPropagatorResult( 45 stateEntry, ModifiedPropertiesBehavior.NoneModified); 46 break; 47 case EntityState.Modified: 48 this.Original = translator.RecordConverter.ConvertOriginalValuesToPropagatorResult( 49 stateEntry, ModifiedPropertiesBehavior.SomeModified); 50 this.Current = translator.RecordConverter.ConvertCurrentValuesToPropagatorResult( 51 stateEntry, ModifiedPropertiesBehavior.SomeModified); 52 break; 53 case EntityState.Added: 54 this.Original = null; 55 this.Current = translator.RecordConverter.ConvertCurrentValuesToPropagatorResult( 56 stateEntry, ModifiedPropertiesBehavior.AllModified); 57 break; 58 default: 59 Debug.Fail("unexpected IEntityStateEntry.State for entity " + stateEntry.State); 60 this.Original = null; 61 this.Current = null; 62 break; 63 } 64 } 65 } 66 } 67