Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Map / Update / Internal / SourceInterpreter.cs / 3 / SourceInterpreter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Data.Objects; using System.Data.Metadata.Edm; namespace System.Data.Mapping.Update.Internal { ////// This class determines the state entries contributing to an expression /// propagated through an update mapping view (values in propagated expressions /// remember where they come from) /// internal class SourceInterpreter { private SourceInterpreter(UpdateTranslator translator, EntitySet sourceTable) { m_stateEntries = new List(); m_translator = translator; m_sourceTable = sourceTable; } private readonly List m_stateEntries; private readonly UpdateTranslator m_translator; private readonly EntitySet m_sourceTable; /// /// Finds all markup associated with the given source. /// /// Source expression. Must not be null. /// Translator containing session information. /// Table from which the exception was thrown (must not be null). ///Markup. internal static ReadOnlyCollectionGetAllStateEntries(PropagatorResult source, UpdateTranslator translator, EntitySet sourceTable) { Debug.Assert(null != source); Debug.Assert(null != sourceTable); SourceInterpreter interpreter = new SourceInterpreter(translator, sourceTable); interpreter.RetrieveResultMarkup(source); return new ReadOnlyCollection (interpreter.m_stateEntries); } private void RetrieveResultMarkup(PropagatorResult source) { Debug.Assert(null != source); if (null != source.StateEntry) { m_stateEntries.Add(source.StateEntry); } long identifier = source.Identifier; if (PropagatorResult.NullIdentifier != identifier) { // if this is an identifier, it may also be registered with an "owner". // Return the owner as well if the owner is also mapped to this table. PropagatorResult owner; if (m_translator.KeyManager.TryGetIdentifierOwner(identifier, out owner) && null != owner.StateEntry && ExtentInScope(owner.StateEntry.EntitySet)) { m_stateEntries.Add(owner.StateEntry); } // Check if are any referential constraints. If so, the entity key // implies that the dependent relationship instance is also being // handled in this result. foreach (IEntityStateEntry stateEntry in m_translator.KeyManager.GetDependentStateEntries(identifier)) { m_stateEntries.Add(stateEntry); } } if (!source.IsSimple && !source.IsNull) { // walk children foreach (PropagatorResult child in source.GetMemberValues()) { RetrieveResultMarkup(child); } } } // Determines whether the given table is in scope for the current source: if the source // table does not map to the source table for this interpreter, it is not in scope // for exceptions thrown from this table. private bool ExtentInScope(EntitySetBase extent) { if (null == extent) { return false; } // determine if the extent is mapped to this table return m_translator.ViewLoader.GetAffectedTables(extent).Contains(m_sourceTable); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Data.Objects; using System.Data.Metadata.Edm; namespace System.Data.Mapping.Update.Internal { ////// This class determines the state entries contributing to an expression /// propagated through an update mapping view (values in propagated expressions /// remember where they come from) /// internal class SourceInterpreter { private SourceInterpreter(UpdateTranslator translator, EntitySet sourceTable) { m_stateEntries = new List(); m_translator = translator; m_sourceTable = sourceTable; } private readonly List m_stateEntries; private readonly UpdateTranslator m_translator; private readonly EntitySet m_sourceTable; /// /// Finds all markup associated with the given source. /// /// Source expression. Must not be null. /// Translator containing session information. /// Table from which the exception was thrown (must not be null). ///Markup. internal static ReadOnlyCollectionGetAllStateEntries(PropagatorResult source, UpdateTranslator translator, EntitySet sourceTable) { Debug.Assert(null != source); Debug.Assert(null != sourceTable); SourceInterpreter interpreter = new SourceInterpreter(translator, sourceTable); interpreter.RetrieveResultMarkup(source); return new ReadOnlyCollection (interpreter.m_stateEntries); } private void RetrieveResultMarkup(PropagatorResult source) { Debug.Assert(null != source); if (null != source.StateEntry) { m_stateEntries.Add(source.StateEntry); } long identifier = source.Identifier; if (PropagatorResult.NullIdentifier != identifier) { // if this is an identifier, it may also be registered with an "owner". // Return the owner as well if the owner is also mapped to this table. PropagatorResult owner; if (m_translator.KeyManager.TryGetIdentifierOwner(identifier, out owner) && null != owner.StateEntry && ExtentInScope(owner.StateEntry.EntitySet)) { m_stateEntries.Add(owner.StateEntry); } // Check if are any referential constraints. If so, the entity key // implies that the dependent relationship instance is also being // handled in this result. foreach (IEntityStateEntry stateEntry in m_translator.KeyManager.GetDependentStateEntries(identifier)) { m_stateEntries.Add(stateEntry); } } if (!source.IsSimple && !source.IsNull) { // walk children foreach (PropagatorResult child in source.GetMemberValues()) { RetrieveResultMarkup(child); } } } // Determines whether the given table is in scope for the current source: if the source // table does not map to the source table for this interpreter, it is not in scope // for exceptions thrown from this table. private bool ExtentInScope(EntitySetBase extent) { if (null == extent) { return false; } // determine if the extent is mapped to this table return m_translator.ViewLoader.GetAffectedTables(extent).Contains(m_sourceTable); } } } // 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
- XmlSchemaAttributeGroupRef.cs
- HttpResponse.cs
- DrawingContextDrawingContextWalker.cs
- DataTableMappingCollection.cs
- SystemWebSectionGroup.cs
- Stopwatch.cs
- Bits.cs
- ReadOnlyCollection.cs
- EntityDataSourceViewSchema.cs
- Span.cs
- SoapEnvelopeProcessingElement.cs
- _HelperAsyncResults.cs
- StatusBar.cs
- IResourceProvider.cs
- XamlGridLengthSerializer.cs
- SqlCaseSimplifier.cs
- SecurityRuntime.cs
- HashHelper.cs
- DBBindings.cs
- Symbol.cs
- CacheManager.cs
- IdentifierService.cs
- InkCollectionBehavior.cs
- ParameterToken.cs
- TreeNodeBinding.cs
- SQLDecimalStorage.cs
- TypeBuilderInstantiation.cs
- TextFormatterImp.cs
- FlowThrottle.cs
- ButtonAutomationPeer.cs
- UrlEncodedParameterWriter.cs
- StdValidatorsAndConverters.cs
- ProfileService.cs
- _ProxyRegBlob.cs
- NamedPipeProcessProtocolHandler.cs
- XmlEntity.cs
- HtmlGenericControl.cs
- MatcherBuilder.cs
- DaylightTime.cs
- BulletedListEventArgs.cs
- WebEvents.cs
- EtwTrace.cs
- x509utils.cs
- CallContext.cs
- ColorBlend.cs
- SpellerHighlightLayer.cs
- HelpInfo.cs
- CodeExpressionStatement.cs
- TableNameAttribute.cs
- UrlMappingCollection.cs
- GridViewSortEventArgs.cs
- CodeDOMUtility.cs
- ReadOnlyHierarchicalDataSource.cs
- localization.cs
- TickBar.cs
- LogRestartAreaEnumerator.cs
- DependencyPropertyDescriptor.cs
- AnnotationService.cs
- LocalizabilityAttribute.cs
- AmbientProperties.cs
- ImageButton.cs
- DataSourceXmlClassAttribute.cs
- VideoDrawing.cs
- HijriCalendar.cs
- ComAdminInterfaces.cs
- DataRecordInfo.cs
- HelpKeywordAttribute.cs
- KnownTypeAttribute.cs
- WebPartTransformerAttribute.cs
- DataObjectMethodAttribute.cs
- InternalDispatchObject.cs
- BinaryOperationBinder.cs
- HtmlInputPassword.cs
- XmlSchemaAppInfo.cs
- FlowLayoutSettings.cs
- JsonEnumDataContract.cs
- Debug.cs
- XmlElementList.cs
- TemplateInstanceAttribute.cs
- CommandValueSerializer.cs
- DBConcurrencyException.cs
- CharEntityEncoderFallback.cs
- MissingManifestResourceException.cs
- SqlBulkCopyColumnMappingCollection.cs
- base64Transforms.cs
- XmlCustomFormatter.cs
- HttpListenerPrefixCollection.cs
- AttachmentService.cs
- DefaultProxySection.cs
- PersistenceTypeAttribute.cs
- MapPathBasedVirtualPathProvider.cs
- AstTree.cs
- CLSCompliantAttribute.cs
- OleDbCommand.cs
- RegexCapture.cs
- InkPresenterAutomationPeer.cs
- AttachedAnnotation.cs
- HScrollProperties.cs
- AdobeCFFWrapper.cs
- ForwardPositionQuery.cs