Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / NavigationProperty.cs / 1305376 / NavigationProperty.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; using System.Threading; using System.Linq; namespace System.Data.Metadata.Edm { ////// Represent the edm navigation property class /// public sealed class NavigationProperty : EdmMember { #region Constructors ////// Initializes a new instance of the navigation property class /// /// name of the navigation property /// TypeUsage object containing the navigation property type and its facets ///Thrown if name or typeUsage arguments are null ///Thrown if name argument is empty string internal NavigationProperty(string name, TypeUsage typeUsage) : base(name, typeUsage) { EntityUtil.CheckStringArgument(name, "name"); EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage"); _accessor = new NavigationPropertyAccessor(name); } ////// Initializes a new OSpace instance of the property class /// /// name of the property /// TypeUsage object containing the property type and its facets /// for the property internal NavigationProperty(string name, TypeUsage typeUsage, System.Reflection.PropertyInfo propertyInfo) : this(name, typeUsage) { System.Diagnostics.Debug.Assert(name == propertyInfo.Name, "different PropertyName?"); if (null != propertyInfo) { System.Reflection.MethodInfo method; method = propertyInfo.GetGetMethod(); PropertyGetterHandle = ((null != method) ? method.MethodHandle : default(System.RuntimeMethodHandle)); } } #endregion ////// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.NavigationProperty; } } #region Fields internal const string RelationshipTypeNamePropertyName = "RelationshipType"; internal const string ToEndMemberNamePropertyName = "ToEndMember"; private RelationshipType _relationshipType; private RelationshipEndMember _toEndMember; private RelationshipEndMember _fromEndMember; ///Store the handle, allowing the PropertyInfo/MethodInfo/Type references to be GC'd internal readonly System.RuntimeMethodHandle PropertyGetterHandle; ///cached dynamic methods to access the property values from a CLR instance private readonly NavigationPropertyAccessor _accessor; #endregion ////// Gets/Sets the relationship type that this navigation property operates on /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipType, false)] public RelationshipType RelationshipType { get { return _relationshipType; } internal set { _relationshipType = value; } } ////// Gets/Sets the to relationship end member in the navigation /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] public RelationshipEndMember ToEndMember { get { return _toEndMember; } internal set { _toEndMember = value; } } ////// Gets/Sets the from relationship end member in the navigation /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] public RelationshipEndMember FromEndMember { get { return _fromEndMember; } internal set { _fromEndMember = value; } } internal NavigationPropertyAccessor Accessor { get { return _accessor; } } ////// Where the given navigation property is on the dependent end of a referential constraint, /// returns the foreign key properties. Otherwise, returns an empty set. We will return the members in the order /// of the principal end key properties. /// ///Foreign key properties public IEnumerableGetDependentProperties() { // Get the declared type AssociationType associationType = (AssociationType)this.RelationshipType; Debug.Assert( associationType.ReferentialConstraints != null, "ReferenceConstraints cannot be null"); if (associationType.ReferentialConstraints.Count > 0) { ReferentialConstraint rc = associationType.ReferentialConstraints[0]; RelationshipEndMember dependentEndMember = rc.ToRole; if (dependentEndMember.EdmEquals(this.FromEndMember)) { //Order the dependant properties in the order of principal end's key members. var keyMembers = rc.FromRole.GetEntityType().KeyMembers; var dependantProperties = new List (keyMembers.Count); for (int i = 0; i < keyMembers.Count; i++) { dependantProperties.Add(rc.ToProperties[rc.FromProperties.IndexOf(((EdmProperty)keyMembers[i]))]); } return dependantProperties.AsReadOnly(); } } return Enumerable.Empty (); } } } // 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.Data.Common; using System.Diagnostics; using System.Threading; using System.Linq; namespace System.Data.Metadata.Edm { ////// Represent the edm navigation property class /// public sealed class NavigationProperty : EdmMember { #region Constructors ////// Initializes a new instance of the navigation property class /// /// name of the navigation property /// TypeUsage object containing the navigation property type and its facets ///Thrown if name or typeUsage arguments are null ///Thrown if name argument is empty string internal NavigationProperty(string name, TypeUsage typeUsage) : base(name, typeUsage) { EntityUtil.CheckStringArgument(name, "name"); EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage"); _accessor = new NavigationPropertyAccessor(name); } ////// Initializes a new OSpace instance of the property class /// /// name of the property /// TypeUsage object containing the property type and its facets /// for the property internal NavigationProperty(string name, TypeUsage typeUsage, System.Reflection.PropertyInfo propertyInfo) : this(name, typeUsage) { System.Diagnostics.Debug.Assert(name == propertyInfo.Name, "different PropertyName?"); if (null != propertyInfo) { System.Reflection.MethodInfo method; method = propertyInfo.GetGetMethod(); PropertyGetterHandle = ((null != method) ? method.MethodHandle : default(System.RuntimeMethodHandle)); } } #endregion ////// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.NavigationProperty; } } #region Fields internal const string RelationshipTypeNamePropertyName = "RelationshipType"; internal const string ToEndMemberNamePropertyName = "ToEndMember"; private RelationshipType _relationshipType; private RelationshipEndMember _toEndMember; private RelationshipEndMember _fromEndMember; ///Store the handle, allowing the PropertyInfo/MethodInfo/Type references to be GC'd internal readonly System.RuntimeMethodHandle PropertyGetterHandle; ///cached dynamic methods to access the property values from a CLR instance private readonly NavigationPropertyAccessor _accessor; #endregion ////// Gets/Sets the relationship type that this navigation property operates on /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipType, false)] public RelationshipType RelationshipType { get { return _relationshipType; } internal set { _relationshipType = value; } } ////// Gets/Sets the to relationship end member in the navigation /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] public RelationshipEndMember ToEndMember { get { return _toEndMember; } internal set { _toEndMember = value; } } ////// Gets/Sets the from relationship end member in the navigation /// ///Thrown if the NavigationProperty instance is in ReadOnly state [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] public RelationshipEndMember FromEndMember { get { return _fromEndMember; } internal set { _fromEndMember = value; } } internal NavigationPropertyAccessor Accessor { get { return _accessor; } } ////// Where the given navigation property is on the dependent end of a referential constraint, /// returns the foreign key properties. Otherwise, returns an empty set. We will return the members in the order /// of the principal end key properties. /// ///Foreign key properties public IEnumerableGetDependentProperties() { // Get the declared type AssociationType associationType = (AssociationType)this.RelationshipType; Debug.Assert( associationType.ReferentialConstraints != null, "ReferenceConstraints cannot be null"); if (associationType.ReferentialConstraints.Count > 0) { ReferentialConstraint rc = associationType.ReferentialConstraints[0]; RelationshipEndMember dependentEndMember = rc.ToRole; if (dependentEndMember.EdmEquals(this.FromEndMember)) { //Order the dependant properties in the order of principal end's key members. var keyMembers = rc.FromRole.GetEntityType().KeyMembers; var dependantProperties = new List (keyMembers.Count); for (int i = 0; i < keyMembers.Count; i++) { dependantProperties.Add(rc.ToProperties[rc.FromProperties.IndexOf(((EdmProperty)keyMembers[i]))]); } return dependantProperties.AsReadOnly(); } } return Enumerable.Empty (); } } } // 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
- UpdateTracker.cs
- PageSetupDialog.cs
- Page.cs
- AnchoredBlock.cs
- SimpleHandlerFactory.cs
- DataGridViewCellFormattingEventArgs.cs
- CodeCastExpression.cs
- CursorInteropHelper.cs
- StateDesigner.LayoutSelectionGlyph.cs
- SerializationEventsCache.cs
- FaultReason.cs
- FreezableCollection.cs
- RunClient.cs
- linebase.cs
- XmlSecureResolver.cs
- BindingsCollection.cs
- HttpApplicationStateBase.cs
- OleDbInfoMessageEvent.cs
- SchemaCollectionPreprocessor.cs
- ObjectSet.cs
- HandlerFactoryWrapper.cs
- PrinterResolution.cs
- DynamicILGenerator.cs
- ToolStripContentPanelRenderEventArgs.cs
- GridItemCollection.cs
- DiscreteKeyFrames.cs
- SpanIndex.cs
- StringSorter.cs
- HwndProxyElementProvider.cs
- TryExpression.cs
- CheckableControlBaseAdapter.cs
- Math.cs
- FunctionCommandText.cs
- SecurityTokenParametersEnumerable.cs
- WebPartHeaderCloseVerb.cs
- XmlNodeList.cs
- DbSourceCommand.cs
- UrlMappingsModule.cs
- XmlBinaryWriter.cs
- BitmapEffectRenderDataResource.cs
- AddInBase.cs
- FormsAuthenticationConfiguration.cs
- TraceRecord.cs
- XmlSchemaAnyAttribute.cs
- UpdateManifestForBrowserApplication.cs
- SystemInformation.cs
- WebPartConnectionCollection.cs
- XmlHierarchyData.cs
- DynamicActivityProperty.cs
- BasicHttpBinding.cs
- InkCanvasFeedbackAdorner.cs
- HandlerBase.cs
- SchemaImporterExtension.cs
- ReadOnlyDictionary.cs
- CoTaskMemSafeHandle.cs
- FileIOPermission.cs
- PageStatePersister.cs
- DelegatingConfigHost.cs
- clipboard.cs
- WrapPanel.cs
- BindingListCollectionView.cs
- ConstructorNeedsTagAttribute.cs
- PopupEventArgs.cs
- ColumnHeader.cs
- _NetworkingPerfCounters.cs
- RelationshipFixer.cs
- InvalidEnumArgumentException.cs
- PeerNameRecord.cs
- SettingsAttributes.cs
- WorkflowMarkupElementEventArgs.cs
- DataViewListener.cs
- TransactionManager.cs
- HandlerFactoryWrapper.cs
- BitmapEffectDrawingContextWalker.cs
- DbQueryCommandTree.cs
- DiffuseMaterial.cs
- WebServiceTypeData.cs
- externdll.cs
- DiffuseMaterial.cs
- DataFieldConverter.cs
- ViewBox.cs
- CompilerGlobalScopeAttribute.cs
- ADRoleFactoryConfiguration.cs
- TableCellAutomationPeer.cs
- HttpWebResponse.cs
- DataBindingList.cs
- FontFamilyValueSerializer.cs
- TrackingProfileCache.cs
- AddingNewEventArgs.cs
- GeneralTransform3D.cs
- HMACSHA1.cs
- DataTableMapping.cs
- documentsequencetextview.cs
- TextServicesProperty.cs
- VisualBrush.cs
- WindowsGraphicsWrapper.cs
- SchemaSetCompiler.cs
- StringPropertyBuilder.cs
- DataGridCaption.cs
- ReliableReplySessionChannel.cs