Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Map / Update / Internal / RecordConverter.cs / 2 / 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
- OpCodes.cs
- TrustLevelCollection.cs
- XslAst.cs
- PreDigestedSignedInfo.cs
- PrintPreviewGraphics.cs
- TextTreeText.cs
- ExtenderControl.cs
- TextPointer.cs
- BitmapEncoder.cs
- FilePrompt.cs
- WindowExtensionMethods.cs
- ValuePattern.cs
- AdapterDictionary.cs
- SiblingIterators.cs
- SystemFonts.cs
- NativeWindow.cs
- XamlPoint3DCollectionSerializer.cs
- HttpServerProtocol.cs
- DbInsertCommandTree.cs
- CodeTypeDeclarationCollection.cs
- EntityFunctions.cs
- ProxyWebPartConnectionCollection.cs
- ObfuscateAssemblyAttribute.cs
- InlinedLocationReference.cs
- ThreadExceptionEvent.cs
- CacheEntry.cs
- ServiceOperationWrapper.cs
- IsolatedStorageFilePermission.cs
- OpenTypeCommon.cs
- BindingListCollectionView.cs
- XmlValueConverter.cs
- TextServicesCompartmentContext.cs
- WebPartVerb.cs
- ToolStripContainer.cs
- NetSectionGroup.cs
- XamlParser.cs
- SiteMapSection.cs
- AssemblyCache.cs
- BaseDataBoundControl.cs
- ByteStream.cs
- AnnotationComponentChooser.cs
- SizeConverter.cs
- CLRBindingWorker.cs
- XslCompiledTransform.cs
- SafeRightsManagementPubHandle.cs
- MemberRelationshipService.cs
- AttributeCollection.cs
- File.cs
- InfoCardSymmetricAlgorithm.cs
- GroupItemAutomationPeer.cs
- HtmlInputHidden.cs
- SystemWebCachingSectionGroup.cs
- MouseActionConverter.cs
- DomainConstraint.cs
- CodeDomConfigurationHandler.cs
- ChannelServices.cs
- DesignerWidgets.cs
- RangeValuePattern.cs
- CompressionTransform.cs
- TimeSpanConverter.cs
- RelationshipEndCollection.cs
- SafeFileHandle.cs
- InvalidMessageContractException.cs
- TextEndOfParagraph.cs
- ComponentResourceManager.cs
- LoginCancelEventArgs.cs
- PageAdapter.cs
- ServicePoint.cs
- WSHttpBindingElement.cs
- PersonalizablePropertyEntry.cs
- FileChangesMonitor.cs
- EventProviderBase.cs
- XmlNamespaceMapping.cs
- DeviceContext.cs
- Privilege.cs
- TagPrefixCollection.cs
- SqlClientWrapperSmiStreamChars.cs
- OdbcPermission.cs
- XmlSchema.cs
- LinqDataSourceStatusEventArgs.cs
- HierarchicalDataBoundControlAdapter.cs
- ExpressionsCollectionEditor.cs
- TextShapeableCharacters.cs
- XPathNavigator.cs
- HwndProxyElementProvider.cs
- ExpressionBinding.cs
- TokenBasedSetEnumerator.cs
- GridViewSortEventArgs.cs
- ConnectionStringsExpressionBuilder.cs
- HeaderFilter.cs
- NamespaceCollection.cs
- ParseNumbers.cs
- StartUpEventArgs.cs
- ScrollBarAutomationPeer.cs
- ProfilePropertyMetadata.cs
- DataGridViewRow.cs
- ClientScriptManager.cs
- Line.cs
- GridViewRowEventArgs.cs
- FolderLevelBuildProviderCollection.cs