Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / EntityContainerRelationshipSetEnd.cs / 2 / EntityContainerRelationshipSetEnd.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an RelationshipSetEnd element. /// internal class EntityContainerRelationshipSetEnd : SchemaElement { private IRelationshipEnd _relationshipEnd; private string _unresolvedEntitySetName; private EntityContainerEntitySet _entitySet; ////// Constructs an EntityContainerRelationshipSetEnd /// /// Reference to the schema element. public EntityContainerRelationshipSetEnd( EntityContainerRelationshipSet parentElement ) : base( parentElement ) { } ////// the End in the parent’s Association that this element refers to /// public IRelationshipEnd RelationshipEnd { get { return _relationshipEnd; } internal set { _relationshipEnd = value; } } public EntityContainerEntitySet EntitySet { get { return _entitySet; } internal set { _entitySet = value; } } protected override bool ProhibitAttribute(string namespaceUri, string localName) { if (base.ProhibitAttribute(namespaceUri, localName)) { return true; } if (namespaceUri == null && localName == XmlConstants.Name) { return false; } return false; } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.EntitySet)) { HandleEntitySetAttribute(reader); return true; } return false; } ////// This is the method that is called when an EntitySet Attribute is encountered. /// /// The XmlRead positned at the extent attribute. private void HandleEntitySetAttribute( XmlReader reader ) { if (Schema.DataModel == SchemaDataModelOption.ProviderDataModel) { // ssdl will take anything, because this is the table name, and we // can't predict what the vendor will need in a table name _unresolvedEntitySetName = reader.Value; } else { _unresolvedEntitySetName = HandleUndottedNameAttribute(reader, _unresolvedEntitySetName); } } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); if ( _entitySet == null ) { _entitySet = this.ParentElement.ParentElement.FindEntitySet( _unresolvedEntitySetName ); if ( _entitySet == null ) { AddError( ErrorCode.InvalidEndEntitySet, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEntitySetNameReference(_unresolvedEntitySetName, Name ) ); } } } ////// Do all validation for this element here, and delegate to all sub elements /// internal override void Validate() { base.Validate(); if ( _relationshipEnd == null || _entitySet == null ) { return; } // We need to allow 2 kind of scenarios: // 1> If you have a relationship type defined between Customer and Order, then you can have a association set in // which the Customer end refers to a Entity Set of type GoodCustomer where GoodCustomer type derives from Customer // 2> If you have a relationship type defined between GoodCustomer and Order, then you can have a relationship // set which GoodCustomer end refers to an entity set whose entity type is Customer (where GoodCustomer derives // from Customer). This scenario enables us to support scenarios where you want specific types in an entity set // to take part in a relationship. if ( !_relationshipEnd.Type.IsOfType( _entitySet.EntityType ) && !_entitySet.EntityType.IsOfType( _relationshipEnd.Type )) { AddError( ErrorCode.InvalidEndEntitySet, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEndEntitySetTypeMismatch(_relationshipEnd.Name ) ); } } ////// The parent element as an EntityContainerProperty /// internal new EntityContainerRelationshipSet ParentElement { get { return (EntityContainerRelationshipSet)( base.ParentElement ); } } } } // 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; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an RelationshipSetEnd element. /// internal class EntityContainerRelationshipSetEnd : SchemaElement { private IRelationshipEnd _relationshipEnd; private string _unresolvedEntitySetName; private EntityContainerEntitySet _entitySet; ////// Constructs an EntityContainerRelationshipSetEnd /// /// Reference to the schema element. public EntityContainerRelationshipSetEnd( EntityContainerRelationshipSet parentElement ) : base( parentElement ) { } ////// the End in the parent’s Association that this element refers to /// public IRelationshipEnd RelationshipEnd { get { return _relationshipEnd; } internal set { _relationshipEnd = value; } } public EntityContainerEntitySet EntitySet { get { return _entitySet; } internal set { _entitySet = value; } } protected override bool ProhibitAttribute(string namespaceUri, string localName) { if (base.ProhibitAttribute(namespaceUri, localName)) { return true; } if (namespaceUri == null && localName == XmlConstants.Name) { return false; } return false; } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.EntitySet)) { HandleEntitySetAttribute(reader); return true; } return false; } ////// This is the method that is called when an EntitySet Attribute is encountered. /// /// The XmlRead positned at the extent attribute. private void HandleEntitySetAttribute( XmlReader reader ) { if (Schema.DataModel == SchemaDataModelOption.ProviderDataModel) { // ssdl will take anything, because this is the table name, and we // can't predict what the vendor will need in a table name _unresolvedEntitySetName = reader.Value; } else { _unresolvedEntitySetName = HandleUndottedNameAttribute(reader, _unresolvedEntitySetName); } } ////// Used during the resolve phase to resolve the type name to the object that represents that type /// internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); if ( _entitySet == null ) { _entitySet = this.ParentElement.ParentElement.FindEntitySet( _unresolvedEntitySetName ); if ( _entitySet == null ) { AddError( ErrorCode.InvalidEndEntitySet, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEntitySetNameReference(_unresolvedEntitySetName, Name ) ); } } } ////// Do all validation for this element here, and delegate to all sub elements /// internal override void Validate() { base.Validate(); if ( _relationshipEnd == null || _entitySet == null ) { return; } // We need to allow 2 kind of scenarios: // 1> If you have a relationship type defined between Customer and Order, then you can have a association set in // which the Customer end refers to a Entity Set of type GoodCustomer where GoodCustomer type derives from Customer // 2> If you have a relationship type defined between GoodCustomer and Order, then you can have a relationship // set which GoodCustomer end refers to an entity set whose entity type is Customer (where GoodCustomer derives // from Customer). This scenario enables us to support scenarios where you want specific types in an entity set // to take part in a relationship. if ( !_relationshipEnd.Type.IsOfType( _entitySet.EntityType ) && !_entitySet.EntityType.IsOfType( _relationshipEnd.Type )) { AddError( ErrorCode.InvalidEndEntitySet, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEndEntitySetTypeMismatch(_relationshipEnd.Name ) ); } } ////// The parent element as an EntityContainerProperty /// internal new EntityContainerRelationshipSet ParentElement { get { return (EntityContainerRelationshipSet)( base.ParentElement ); } } } } // 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
- CodeIdentifier.cs
- IdleTimeoutMonitor.cs
- ClonableStack.cs
- ImageListStreamer.cs
- LocatorPartList.cs
- FormViewDeletedEventArgs.cs
- COM2ExtendedBrowsingHandler.cs
- MenuItemBinding.cs
- OptimisticConcurrencyException.cs
- ConnectionStringsExpressionBuilder.cs
- TraceHandler.cs
- StatusBarItemAutomationPeer.cs
- GatewayIPAddressInformationCollection.cs
- StrokeNodeOperations.cs
- ClockController.cs
- VirtualPathData.cs
- HttpStreamXmlDictionaryWriter.cs
- ExpressionDumper.cs
- AlphaSortedEnumConverter.cs
- CustomErrorCollection.cs
- OletxTransactionManager.cs
- MachineKeyValidationConverter.cs
- MailDefinition.cs
- DataSourceComponent.cs
- DataGridViewMethods.cs
- SQLInt16.cs
- ValuePattern.cs
- PersistNameAttribute.cs
- TemplateParser.cs
- LongCountAggregationOperator.cs
- AdapterDictionary.cs
- X509Certificate2Collection.cs
- DecimalConverter.cs
- DataGridPageChangedEventArgs.cs
- SerializationException.cs
- WindowVisualStateTracker.cs
- EntityReference.cs
- _SslSessionsCache.cs
- MarkupObject.cs
- ProviderUtil.cs
- figurelengthconverter.cs
- CellParaClient.cs
- CodeMemberEvent.cs
- XmlSchemaIdentityConstraint.cs
- WorkflowDurableInstance.cs
- InfoCardKeyedHashAlgorithm.cs
- EdmConstants.cs
- GraphicsState.cs
- TypeConstant.cs
- EntityDataSourceContextCreatedEventArgs.cs
- HMACSHA384.cs
- MDIWindowDialog.cs
- DiagnosticsConfiguration.cs
- HtmlGenericControl.cs
- Span.cs
- IntSecurity.cs
- XNodeValidator.cs
- SecurityContextCookieSerializer.cs
- QueryCursorEventArgs.cs
- ChannelManagerService.cs
- _ListenerAsyncResult.cs
- BasicCellRelation.cs
- storepermission.cs
- ComPlusDiagnosticTraceSchemas.cs
- EntitySetRetriever.cs
- BuildProvidersCompiler.cs
- SlipBehavior.cs
- SQLInt16.cs
- DataTableCollection.cs
- OracleBoolean.cs
- ObjectDataSourceMethodEventArgs.cs
- EntityDataSourceSelectingEventArgs.cs
- CryptoApi.cs
- ScriptBehaviorDescriptor.cs
- AnimatedTypeHelpers.cs
- ArraySegment.cs
- ConfigXmlAttribute.cs
- ValueSerializerAttribute.cs
- ExistsInCollection.cs
- InputScopeAttribute.cs
- PersistenceException.cs
- TraceFilter.cs
- ContainerVisual.cs
- SqlBooleanizer.cs
- DateTime.cs
- TypeDelegator.cs
- SqlBinder.cs
- RoleManagerSection.cs
- SqlDataSourceAdvancedOptionsForm.cs
- UnsignedPublishLicense.cs
- OutputCacheSection.cs
- TextDecorationCollection.cs
- SqlTriggerAttribute.cs
- updateconfighost.cs
- BuildProviderInstallComponent.cs
- ErrorStyle.cs
- WeakReadOnlyCollection.cs
- ReadOnlyCollection.cs
- Base64Encoder.cs
- latinshape.cs