Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Map / Update / Internal / RecordConverter.cs / 1 / RecordConverter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common; using System.Data.Metadata.Edm; using System.Data.Objects; using System.Collections.Generic; using System.Data.Common.Utils; using System.Collections; using System.Data.Entity; namespace System.Data.Mapping.Update.Internal { ////// Converts records to new instance expressions. Assumes that all inputs come from a single data reader (because /// it caches record layout). If multiple readers are used, multiple converters must be constructed in case /// the different readers return different layouts for types. /// ////// Conventions for modifiedProperties enumeration: null means all properties are modified, empty means none, /// non-empty means some. /// internal class RecordConverter { #region Constructors ////// Initializes a new converter given a command tree context. Initializes a new record layout cache. /// /// Setsinternal RecordConverter(UpdateTranslator updateTranslator) { m_updateTranslator = updateTranslator; } #endregion #region Fields /// /// Context used to produce expressions. /// private UpdateTranslator m_updateTranslator; #endregion #region Methods ////// Converts original values in a state entry to a DbNewInstanceExpression. The record must be either an entity or /// a relationship set instance. /// ////// This method is not thread safe. /// /// Gets state entry this record is associated with. /// A list of modified properties. See remarks on this class for details. ///New instance expression. internal PropagatorResult ConvertOriginalValuesToPropagatorResult(IEntityStateEntry stateEntry, IEnumerablemodifiedProperties) { return ConvertStateEntryToPropagatorResult(stateEntry, modifiedProperties, true /*useOriginalValues*/); } /// /// Converts current values in a state entry to a DbNewInstanceExpression. The record must be either an entity or /// a relationship set instance. /// ////// This method is not thread safe. /// /// Gets state entry this record is associated with. /// A list of modified properties. See remarks on this class for details. ///New instance expression. internal PropagatorResult ConvertCurrentValuesToPropagatorResult(IEntityStateEntry stateEntry, IEnumerablemodifiedProperties) { return ConvertStateEntryToPropagatorResult(stateEntry, modifiedProperties, false /*useOriginalValues*/); } private PropagatorResult ConvertStateEntryToPropagatorResult(IEntityStateEntry stateEntry, IEnumerable modifiedProperties, bool useOriginalValues) { try { EntityUtil.CheckArgumentNull(stateEntry, "stateEntry"); IExtendedDataRecord record = useOriginalValues ? EntityUtil.CheckArgumentNull(stateEntry.OriginalValues as IExtendedDataRecord, "stateEntry.OriginalValues") : EntityUtil.CheckArgumentNull(stateEntry.CurrentValues as IExtendedDataRecord, "stateEntry.CurrentValues"); bool isModified = false; // the root of the state entry is unchanged because the type is static return ExtractorMetadata.ExtractResultFromRecord(stateEntry, isModified, record, modifiedProperties, m_updateTranslator); } catch (Exception e) { if (UpdateTranslator.RequiresContext(e)) { throw EntityUtil.Update(Strings.Update_ErrorLoadingRecord, e, stateEntry); } throw; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common; using System.Data.Metadata.Edm; using System.Data.Objects; using System.Collections.Generic; using System.Data.Common.Utils; using System.Collections; using System.Data.Entity; namespace System.Data.Mapping.Update.Internal { ////// Converts records to new instance expressions. Assumes that all inputs come from a single data reader (because /// it caches record layout). If multiple readers are used, multiple converters must be constructed in case /// the different readers return different layouts for types. /// ////// Conventions for modifiedProperties enumeration: null means all properties are modified, empty means none, /// non-empty means some. /// internal class RecordConverter { #region Constructors ////// Initializes a new converter given a command tree context. Initializes a new record layout cache. /// /// Setsinternal RecordConverter(UpdateTranslator updateTranslator) { m_updateTranslator = updateTranslator; } #endregion #region Fields /// /// Context used to produce expressions. /// private UpdateTranslator m_updateTranslator; #endregion #region Methods ////// Converts original values in a state entry to a DbNewInstanceExpression. The record must be either an entity or /// a relationship set instance. /// ////// This method is not thread safe. /// /// Gets state entry this record is associated with. /// A list of modified properties. See remarks on this class for details. ///New instance expression. internal PropagatorResult ConvertOriginalValuesToPropagatorResult(IEntityStateEntry stateEntry, IEnumerablemodifiedProperties) { return ConvertStateEntryToPropagatorResult(stateEntry, modifiedProperties, true /*useOriginalValues*/); } /// /// Converts current values in a state entry to a DbNewInstanceExpression. The record must be either an entity or /// a relationship set instance. /// ////// This method is not thread safe. /// /// Gets state entry this record is associated with. /// A list of modified properties. See remarks on this class for details. ///New instance expression. internal PropagatorResult ConvertCurrentValuesToPropagatorResult(IEntityStateEntry stateEntry, IEnumerablemodifiedProperties) { return ConvertStateEntryToPropagatorResult(stateEntry, modifiedProperties, false /*useOriginalValues*/); } private PropagatorResult ConvertStateEntryToPropagatorResult(IEntityStateEntry stateEntry, IEnumerable modifiedProperties, bool useOriginalValues) { try { EntityUtil.CheckArgumentNull(stateEntry, "stateEntry"); IExtendedDataRecord record = useOriginalValues ? EntityUtil.CheckArgumentNull(stateEntry.OriginalValues as IExtendedDataRecord, "stateEntry.OriginalValues") : EntityUtil.CheckArgumentNull(stateEntry.CurrentValues as IExtendedDataRecord, "stateEntry.CurrentValues"); bool isModified = false; // the root of the state entry is unchanged because the type is static return ExtractorMetadata.ExtractResultFromRecord(stateEntry, isModified, record, modifiedProperties, m_updateTranslator); } catch (Exception e) { if (UpdateTranslator.RequiresContext(e)) { throw EntityUtil.Update(Strings.Update_ErrorLoadingRecord, e, stateEntry); } throw; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TraceUtils.cs
- MultilineStringEditor.cs
- KeyboardNavigation.cs
- ServicesSection.cs
- NotSupportedException.cs
- HostedElements.cs
- WebServiceResponseDesigner.cs
- StateItem.cs
- CancelEventArgs.cs
- MbpInfo.cs
- ObjectManager.cs
- XhtmlTextWriter.cs
- QilReplaceVisitor.cs
- LightweightCodeGenerator.cs
- FileDialogCustomPlace.cs
- BindingListCollectionView.cs
- ClientScriptManager.cs
- DescendentsWalkerBase.cs
- RequestBringIntoViewEventArgs.cs
- activationcontext.cs
- __Filters.cs
- ProfileSection.cs
- VerticalAlignConverter.cs
- MessageParameterAttribute.cs
- TransformerInfo.cs
- ToggleProviderWrapper.cs
- RawStylusInputReport.cs
- BmpBitmapDecoder.cs
- ClientOptions.cs
- InputScope.cs
- FloaterParaClient.cs
- CanonicalXml.cs
- NamespaceList.cs
- StrongNameUtility.cs
- AttributeQuery.cs
- IImplicitResourceProvider.cs
- LabelExpression.cs
- WebServicesInteroperability.cs
- ActiveXContainer.cs
- DiagnosticsConfigurationHandler.cs
- ModelPropertyDescriptor.cs
- bidPrivateBase.cs
- TableLayoutPanelDesigner.cs
- DesignerDataSchemaClass.cs
- PrivilegedConfigurationManager.cs
- PropertyValueEditor.cs
- UserPreferenceChangedEventArgs.cs
- ScriptModule.cs
- GeneralTransform3D.cs
- ADMembershipUser.cs
- Scene3D.cs
- WebPartsPersonalizationAuthorization.cs
- IsolatedStorageFile.cs
- CommandBinding.cs
- ScrollData.cs
- TranslateTransform3D.cs
- CategoryNameCollection.cs
- StylusButton.cs
- PrintDialogException.cs
- securitycriticaldataClass.cs
- PackageRelationshipCollection.cs
- MulticastNotSupportedException.cs
- LabelAutomationPeer.cs
- SemanticResolver.cs
- SemanticTag.cs
- ToolStripComboBox.cs
- StateItem.cs
- TraceFilter.cs
- UrlAuthFailedErrorFormatter.cs
- CacheAxisQuery.cs
- DesignerForm.cs
- GeneralTransformGroup.cs
- TextLineResult.cs
- BindingList.cs
- BindingCollectionElement.cs
- ReferenceEqualityComparer.cs
- MergablePropertyAttribute.cs
- PrePrepareMethodAttribute.cs
- AttributeUsageAttribute.cs
- storepermissionattribute.cs
- SwitchLevelAttribute.cs
- Lease.cs
- ConnectionPoint.cs
- documentsequencetextview.cs
- DesignerToolboxInfo.cs
- ExpandedWrapper.cs
- cache.cs
- Socket.cs
- ContractComponent.cs
- AddInActivator.cs
- PointF.cs
- BitmapMetadataEnumerator.cs
- DesignerDeviceConfig.cs
- Roles.cs
- _Connection.cs
- RoutedUICommand.cs
- NeedSkipTokenVisitor.cs
- FileUtil.cs
- RegisterInfo.cs
- DocumentPageView.cs