Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / NavigationProperty.cs / 2 / NavigationProperty.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Summary description for Association. /// [System.Diagnostics.DebuggerDisplay("Name={Name}, Relationship={_unresolvedRelationshipName}, FromRole={_unresolvedFromEndRole}, ToRole={_unresolvedToEndRole}")] internal sealed class NavigationProperty : Property { private string _unresolvedFromEndRole = null; private string _unresolvedToEndRole = null; private string _unresolvedRelationshipName = null; private IRelationshipEnd _fromEnd = null; private IRelationshipEnd _toEnd = null; private IRelationship _relationship = null; ////// /// /// public NavigationProperty(SchemaEntityType parent) : base(parent) { } ////// /// public new SchemaEntityType ParentElement { get { return base.ParentElement as SchemaEntityType; } } internal IRelationship Relationship { get { return _relationship; } } internal IRelationshipEnd ToEnd { get { return _toEnd; } } internal IRelationshipEnd FromEnd { get { return _fromEnd; } } ////// Gets the Type of the property /// public override SchemaType Type { get { if (_toEnd == null || _toEnd.Type == null) { return null; } return _toEnd.Type; } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Relationship)) { HandleAssociationAttribute(reader); return true; } else if (CanHandleAttribute(reader, XmlConstants.FromRole)) { HandleFromRoleAttribute(reader); return true; } else if (CanHandleAttribute(reader, XmlConstants.ToRole)) { HandleToRoleAttribute(reader); return true; } return false; } ////// /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); SchemaType element; if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element)) return; _relationship = element as IRelationship; if (_relationship == null) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName)); return; } bool foundBothEnds = true; if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd)) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName)); foundBothEnds = false; } if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd)) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName)); foundBothEnds = false; } if (foundBothEnds && _fromEnd == _toEnd) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyRolesCannotBeTheSame); } } ////// /// internal override void Validate() { base.Validate(); System.Diagnostics.Debug.Assert(_fromEnd != null && _toEnd != null, "FromEnd and ToEnd must not be null in Validate. ResolveNames must have resolved it or added error"); if (_fromEnd.Type != ParentElement) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyBadFromRoleType(this.Name, _fromEnd.Type.FQName, _fromEnd.Name, _relationship.FQName, ParentElement.FQName)); } StructuredType type = _toEnd.Type; } #region Private Methods ////// /// /// private void HandleToRoleAttribute(XmlReader reader) { _unresolvedToEndRole = HandleUndottedNameAttribute(reader, _unresolvedToEndRole); } ////// /// /// private void HandleFromRoleAttribute(XmlReader reader) { _unresolvedFromEndRole = HandleUndottedNameAttribute(reader, _unresolvedFromEndRole); } ////// /// /// private void HandleAssociationAttribute(XmlReader reader) { if (_unresolvedRelationshipName != null) { AddAlreadyDefinedError(reader); return; } string association; if (!Utils.GetDottedName(this.Schema, reader, out association)) return; _unresolvedRelationshipName = association; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Summary description for Association. /// [System.Diagnostics.DebuggerDisplay("Name={Name}, Relationship={_unresolvedRelationshipName}, FromRole={_unresolvedFromEndRole}, ToRole={_unresolvedToEndRole}")] internal sealed class NavigationProperty : Property { private string _unresolvedFromEndRole = null; private string _unresolvedToEndRole = null; private string _unresolvedRelationshipName = null; private IRelationshipEnd _fromEnd = null; private IRelationshipEnd _toEnd = null; private IRelationship _relationship = null; ////// /// /// public NavigationProperty(SchemaEntityType parent) : base(parent) { } ////// /// public new SchemaEntityType ParentElement { get { return base.ParentElement as SchemaEntityType; } } internal IRelationship Relationship { get { return _relationship; } } internal IRelationshipEnd ToEnd { get { return _toEnd; } } internal IRelationshipEnd FromEnd { get { return _fromEnd; } } ////// Gets the Type of the property /// public override SchemaType Type { get { if (_toEnd == null || _toEnd.Type == null) { return null; } return _toEnd.Type; } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Relationship)) { HandleAssociationAttribute(reader); return true; } else if (CanHandleAttribute(reader, XmlConstants.FromRole)) { HandleFromRoleAttribute(reader); return true; } else if (CanHandleAttribute(reader, XmlConstants.ToRole)) { HandleToRoleAttribute(reader); return true; } return false; } ////// /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); SchemaType element; if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element)) return; _relationship = element as IRelationship; if (_relationship == null) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName)); return; } bool foundBothEnds = true; if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd)) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName)); foundBothEnds = false; } if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd)) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName)); foundBothEnds = false; } if (foundBothEnds && _fromEnd == _toEnd) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyRolesCannotBeTheSame); } } ////// /// internal override void Validate() { base.Validate(); System.Diagnostics.Debug.Assert(_fromEnd != null && _toEnd != null, "FromEnd and ToEnd must not be null in Validate. ResolveNames must have resolved it or added error"); if (_fromEnd.Type != ParentElement) { AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.BadNavigationPropertyBadFromRoleType(this.Name, _fromEnd.Type.FQName, _fromEnd.Name, _relationship.FQName, ParentElement.FQName)); } StructuredType type = _toEnd.Type; } #region Private Methods ////// /// /// private void HandleToRoleAttribute(XmlReader reader) { _unresolvedToEndRole = HandleUndottedNameAttribute(reader, _unresolvedToEndRole); } ////// /// /// private void HandleFromRoleAttribute(XmlReader reader) { _unresolvedFromEndRole = HandleUndottedNameAttribute(reader, _unresolvedFromEndRole); } ////// /// /// private void HandleAssociationAttribute(XmlReader reader) { if (_unresolvedRelationshipName != null) { AddAlreadyDefinedError(reader); return; } string association; if (!Utils.GetDottedName(this.Schema, reader, out association)) return; _unresolvedRelationshipName = association; } #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
- CommunicationObject.cs
- EntityStoreSchemaGenerator.cs
- PageAsyncTask.cs
- FontCollection.cs
- ObjectStorage.cs
- SHA512.cs
- RequestNavigateEventArgs.cs
- PageMediaType.cs
- keycontainerpermission.cs
- DecoratedNameAttribute.cs
- CommandPlan.cs
- XPathChildIterator.cs
- columnmapkeybuilder.cs
- MemoryMappedViewAccessor.cs
- KeysConverter.cs
- BamlResourceSerializer.cs
- Help.cs
- UserNamePasswordServiceCredential.cs
- CodeBinaryOperatorExpression.cs
- HtmlElementErrorEventArgs.cs
- HTTPNotFoundHandler.cs
- PrinterSettings.cs
- ServiceNameCollection.cs
- WebRequestModuleElement.cs
- InternalPolicyElement.cs
- UnlockInstanceAsyncResult.cs
- ControlPersister.cs
- TextEndOfParagraph.cs
- CodeTypeConstructor.cs
- ObjectPropertyMapping.cs
- FixedSOMTextRun.cs
- DbConnectionPoolGroup.cs
- ExceptionTrace.cs
- X509SecurityTokenAuthenticator.cs
- Int16Converter.cs
- BoundField.cs
- TerminatorSinks.cs
- Stopwatch.cs
- HtmlInputButton.cs
- WmlPageAdapter.cs
- PerformanceCounter.cs
- XmlDocumentFragment.cs
- MimePart.cs
- ConstraintConverter.cs
- RbTree.cs
- XmlSchemaSimpleContentRestriction.cs
- BatchParser.cs
- WmpBitmapDecoder.cs
- ApplicationException.cs
- WindowsFormsSynchronizationContext.cs
- StatusBarItem.cs
- EmptyEnumerator.cs
- XmlNodeComparer.cs
- XmlAttributeCollection.cs
- HTMLTextWriter.cs
- XmlSchemaElement.cs
- ProcessingInstructionAction.cs
- DecimalAnimationUsingKeyFrames.cs
- SecurityState.cs
- WebPartZone.cs
- XmlStringTable.cs
- ResetableIterator.cs
- TypeHelpers.cs
- PrintDialog.cs
- securitycriticaldata.cs
- DrawingVisualDrawingContext.cs
- ServerIdentity.cs
- TTSEngineProxy.cs
- ExpressionBindings.cs
- HttpConfigurationSystem.cs
- CharEntityEncoderFallback.cs
- SequenceNumber.cs
- DataContext.cs
- FullTextState.cs
- StorageEntitySetMapping.cs
- BindingCollectionElement.cs
- AppSettingsExpressionBuilder.cs
- ACE.cs
- ErrorHandler.cs
- PeerResolverMode.cs
- MemberDomainMap.cs
- WebPartZoneBase.cs
- ScriptingRoleServiceSection.cs
- _HeaderInfo.cs
- AssociativeAggregationOperator.cs
- ActionMismatchAddressingException.cs
- XamlPoint3DCollectionSerializer.cs
- EventEntry.cs
- ManipulationLogic.cs
- CompiledAction.cs
- ProcessInputEventArgs.cs
- DictionaryChange.cs
- WorkflowEnvironment.cs
- RadioButtonList.cs
- ListViewDeleteEventArgs.cs
- cookie.cs
- MiniMapControl.xaml.cs
- InputReport.cs
- PkcsMisc.cs
- CommonDialog.cs