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 / Relationship.cs / 2 / Relationship.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Data.Objects.DataClasses; using System.Collections.Generic; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an Association element /// internal sealed class Relationship : SchemaType, IRelationship { private RelationshipKind _relationshipKind; RelationshipEndCollection _ends; private List_constraints; /// /// Construct a Relationship object /// /// the parent /// the kind of relationship public Relationship(Schema parent, RelationshipKind kind) : base(parent) { RelationshipKind = kind; } ////// List of Ends defined for this Association /// public IListEnds { get { if ( _ends == null ) _ends = new RelationshipEndCollection(); return _ends; } } /// /// Returns the list of constraints on this relation /// public IListConstraints { get { if (_constraints == null) { _constraints = new List (); } return _constraints; } } public bool TryGetEnd( string roleName, out IRelationshipEnd end ) { return _ends.TryGetEnd( roleName, out end ); } /// /// Is this an Association /// public RelationshipKind RelationshipKind { get { return _relationshipKind; } private set { _relationshipKind = value; } } ////// do whole element validation /// ///internal override void Validate() { base.Validate(); bool foundOperations = false; foreach ( RelationshipEnd end in Ends ) { end.Validate(); if ( RelationshipKind == RelationshipKind.Association ) { if ( end.Operations.Count > 0 ) { if ( foundOperations ) end.AddError( ErrorCode.InvalidOperation, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidOperationMultipleEndsInAssociation); foundOperations = true; } } } if (Constraints.Count == 0 && this.Schema.DataModel == SchemaDataModelOption.ProviderDataModel) { AddError(ErrorCode.MissingConstraintOnRelationshipType, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.MissingConstraintOnRelationshipType(FQName)); } else { foreach (ReferentialConstraint constraint in Constraints) { constraint.Validate(); } } } /// /// do whole element resolution /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); foreach ( RelationshipEnd end in Ends ) end.ResolveTopLevelNames(); foreach (ReferentialConstraint referentialConstraint in Constraints) { referentialConstraint.ResolveTopLevelNames(); } } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.End)) { HandleEndElement(reader); return true; } else if (CanHandleElement(reader, XmlConstants.ReferentialConstraint)) { HandleConstraintElement(reader); return true; } return false; } ////// handle the End child element /// /// XmlReader positioned at the end element private void HandleEndElement(XmlReader reader) { Debug.Assert(reader != null); RelationshipEnd end = new RelationshipEnd(this); end.Parse(reader); if (Ends.Count == 2) { AddError( ErrorCode.InvalidAssociation, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.TooManyAssociationEnds(FQName ) ); return; } Ends.Add(end); } ////// handle the constraint element /// /// XmlReader positioned at the constraint element private void HandleConstraintElement(XmlReader reader) { Debug.Assert(reader != null); ReferentialConstraint constraint = new ReferentialConstraint(this); constraint.Parse(reader); this.Constraints.Add(constraint); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Data.Objects.DataClasses; using System.Collections.Generic; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an Association element /// internal sealed class Relationship : SchemaType, IRelationship { private RelationshipKind _relationshipKind; RelationshipEndCollection _ends; private List_constraints; /// /// Construct a Relationship object /// /// the parent /// the kind of relationship public Relationship(Schema parent, RelationshipKind kind) : base(parent) { RelationshipKind = kind; } ////// List of Ends defined for this Association /// public IListEnds { get { if ( _ends == null ) _ends = new RelationshipEndCollection(); return _ends; } } /// /// Returns the list of constraints on this relation /// public IListConstraints { get { if (_constraints == null) { _constraints = new List (); } return _constraints; } } public bool TryGetEnd( string roleName, out IRelationshipEnd end ) { return _ends.TryGetEnd( roleName, out end ); } /// /// Is this an Association /// public RelationshipKind RelationshipKind { get { return _relationshipKind; } private set { _relationshipKind = value; } } ////// do whole element validation /// ///internal override void Validate() { base.Validate(); bool foundOperations = false; foreach ( RelationshipEnd end in Ends ) { end.Validate(); if ( RelationshipKind == RelationshipKind.Association ) { if ( end.Operations.Count > 0 ) { if ( foundOperations ) end.AddError( ErrorCode.InvalidOperation, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidOperationMultipleEndsInAssociation); foundOperations = true; } } } if (Constraints.Count == 0 && this.Schema.DataModel == SchemaDataModelOption.ProviderDataModel) { AddError(ErrorCode.MissingConstraintOnRelationshipType, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.MissingConstraintOnRelationshipType(FQName)); } else { foreach (ReferentialConstraint constraint in Constraints) { constraint.Validate(); } } } /// /// do whole element resolution /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); foreach ( RelationshipEnd end in Ends ) end.ResolveTopLevelNames(); foreach (ReferentialConstraint referentialConstraint in Constraints) { referentialConstraint.ResolveTopLevelNames(); } } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.End)) { HandleEndElement(reader); return true; } else if (CanHandleElement(reader, XmlConstants.ReferentialConstraint)) { HandleConstraintElement(reader); return true; } return false; } ////// handle the End child element /// /// XmlReader positioned at the end element private void HandleEndElement(XmlReader reader) { Debug.Assert(reader != null); RelationshipEnd end = new RelationshipEnd(this); end.Parse(reader); if (Ends.Count == 2) { AddError( ErrorCode.InvalidAssociation, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.TooManyAssociationEnds(FQName ) ); return; } Ends.Add(end); } ////// handle the constraint element /// /// XmlReader positioned at the constraint element private void HandleConstraintElement(XmlReader reader) { Debug.Assert(reader != null); ReferentialConstraint constraint = new ReferentialConstraint(this); constraint.Parse(reader); this.Constraints.Add(constraint); } } } // 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
- SymbolDocumentGenerator.cs
- SkinIDTypeConverter.cs
- ListViewTableCell.cs
- Rect3D.cs
- UriExt.cs
- CngProperty.cs
- PrintController.cs
- RegexWorker.cs
- TextEditorSelection.cs
- dataprotectionpermissionattribute.cs
- SchemaTableOptionalColumn.cs
- HashHelper.cs
- StreamAsIStream.cs
- ExpressionHelper.cs
- ItemCollection.cs
- PathNode.cs
- DomainUpDown.cs
- HandleExceptionArgs.cs
- Bind.cs
- CodeDOMProvider.cs
- DataColumnPropertyDescriptor.cs
- AppLevelCompilationSectionCache.cs
- ImplicitInputBrush.cs
- TagNameToTypeMapper.cs
- NoPersistProperty.cs
- Events.cs
- ExpandCollapsePattern.cs
- GridView.cs
- VerificationException.cs
- PointIndependentAnimationStorage.cs
- XamlWriter.cs
- LocalizableAttribute.cs
- FamilyTypeface.cs
- CodeIdentifier.cs
- DataGridViewSortCompareEventArgs.cs
- CharacterMetrics.cs
- TemplatedAdorner.cs
- XamlSerializerUtil.cs
- XmlEncodedRawTextWriter.cs
- OdbcErrorCollection.cs
- ExpressionBinding.cs
- WebEncodingValidator.cs
- XmlBoundElement.cs
- MultiplexingFormatMapping.cs
- TextViewSelectionProcessor.cs
- ComProxy.cs
- CheckBox.cs
- FixedSOMTableRow.cs
- ChangePassword.cs
- PrintPreviewControl.cs
- MasterPageCodeDomTreeGenerator.cs
- HttpListenerResponse.cs
- Emitter.cs
- HtmlInputImage.cs
- PropertyConverter.cs
- BatchParser.cs
- CfgParser.cs
- ErrorInfoXmlDocument.cs
- AutoGeneratedFieldProperties.cs
- WeakReadOnlyCollection.cs
- EllipticalNodeOperations.cs
- JavaScriptString.cs
- DPTypeDescriptorContext.cs
- ServiceOperationUIEditor.cs
- WCFModelStrings.Designer.cs
- EdmValidator.cs
- LinkClickEvent.cs
- TextLine.cs
- Model3DCollection.cs
- SqlTypeSystemProvider.cs
- WebZone.cs
- DataGridViewToolTip.cs
- InputLangChangeEvent.cs
- ZipIOLocalFileBlock.cs
- ProgressBarAutomationPeer.cs
- Int32Storage.cs
- sqlstateclientmanager.cs
- WebPartCollection.cs
- MethodBuilder.cs
- BindingListCollectionView.cs
- Int32Collection.cs
- objectresult_tresulttype.cs
- ServiceDocument.cs
- EntityCommand.cs
- HandlerWithFactory.cs
- RelationshipType.cs
- EntityDataSourceStatementEditorForm.cs
- SqlVisitor.cs
- Socket.cs
- AssociationEndMember.cs
- HttpProfileGroupBase.cs
- SqlDataReaderSmi.cs
- altserialization.cs
- ManifestSignatureInformation.cs
- ManifestBasedResourceGroveler.cs
- HostedHttpContext.cs
- CompositeControl.cs
- CodeMemberMethod.cs
- ObjectItemCollection.cs
- DragDeltaEventArgs.cs