Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / Update / Internal / SourceInterpreter.cs / 1305376 / 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 != translator); 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 (source.Identifier != PropagatorResult.NullIdentifier) { // state entries travel with identifiers. several state entries may be merged // into a single identifier result via joins in the update mapping view do { if (null != source.StateEntry) { m_stateEntries.Add(source.StateEntry); if (source.Identifier != PropagatorResult.NullIdentifier) { // 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(source.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(source.Identifier)) { m_stateEntries.Add(stateEntry); } } } source = source.Next; } while (null != source); } else 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, m_translator.MetadataWorkspace).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 != translator); 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 (source.Identifier != PropagatorResult.NullIdentifier) { // state entries travel with identifiers. several state entries may be merged // into a single identifier result via joins in the update mapping view do { if (null != source.StateEntry) { m_stateEntries.Add(source.StateEntry); if (source.Identifier != PropagatorResult.NullIdentifier) { // 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(source.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(source.Identifier)) { m_stateEntries.Add(stateEntry); } } } source = source.Next; } while (null != source); } else 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, m_translator.MetadataWorkspace).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
- CellRelation.cs
- StaticTextPointer.cs
- LessThan.cs
- ClientUrlResolverWrapper.cs
- filewebresponse.cs
- ProfileService.cs
- IconHelper.cs
- PenContexts.cs
- ModuleBuilder.cs
- Visitor.cs
- DCSafeHandle.cs
- basevalidator.cs
- UpdatePanelTriggerCollection.cs
- __Error.cs
- SecurityException.cs
- CapabilitiesState.cs
- ClockController.cs
- DomainConstraint.cs
- FilterEventArgs.cs
- RemotingConfiguration.cs
- Membership.cs
- DirectoryInfo.cs
- FixedSOMFixedBlock.cs
- HtmlListAdapter.cs
- GridViewEditEventArgs.cs
- oledbconnectionstring.cs
- SizeAnimationBase.cs
- CategoryNameCollection.cs
- TextEditorSelection.cs
- CqlLexer.cs
- Bold.cs
- FocusManager.cs
- SystemTcpStatistics.cs
- followingquery.cs
- GlyphingCache.cs
- SapiRecoInterop.cs
- SafeNativeMethods.cs
- PagesSection.cs
- Route.cs
- CreateUserErrorEventArgs.cs
- EnumerableRowCollection.cs
- MsmqInputChannel.cs
- ScrollItemPattern.cs
- ActivityValidationServices.cs
- RuntimeWrappedException.cs
- ListViewTableCell.cs
- ImageListStreamer.cs
- GlobalProxySelection.cs
- CalendarTable.cs
- DataGridViewControlCollection.cs
- TrackingRecord.cs
- OutputCacheProfileCollection.cs
- ToolBar.cs
- VerticalAlignConverter.cs
- TableRowCollection.cs
- TraceSource.cs
- SecurityManager.cs
- QueryOperationResponseOfT.cs
- DataObjectPastingEventArgs.cs
- CuspData.cs
- TemplateControlCodeDomTreeGenerator.cs
- parserscommon.cs
- HtmlTernaryTree.cs
- DeriveBytes.cs
- Util.cs
- ComboBoxRenderer.cs
- FileChangeNotifier.cs
- Matrix3D.cs
- RubberbandSelector.cs
- TemplateControlParser.cs
- FilterableAttribute.cs
- xmlglyphRunInfo.cs
- TimeEnumHelper.cs
- GuidelineSet.cs
- StringDictionaryCodeDomSerializer.cs
- RadioButton.cs
- RsaKeyGen.cs
- OciLobLocator.cs
- ADRoleFactory.cs
- HttpWriter.cs
- SafeNativeMethods.cs
- ObfuscationAttribute.cs
- IndexingContentUnit.cs
- EncryptedType.cs
- RoleGroup.cs
- EntityTypeBase.cs
- BooleanExpr.cs
- WebPartTransformer.cs
- NavigatorInput.cs
- TextTreeObjectNode.cs
- AssemblyAttributes.cs
- AvtEvent.cs
- BaseDataList.cs
- TransformPatternIdentifiers.cs
- Context.cs
- XmlDocumentFragment.cs
- ErrorTolerantObjectWriter.cs
- DLinqAssociationProvider.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- TypeTypeConverter.cs