Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / ReferentialConstraint.cs / 1 / ReferentialConstraint.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
namespace System.Data.Metadata.Edm
{
///
/// This class describes referential constraint on the relationships
///
public sealed class ReferentialConstraint : MetadataItem
{
#region Constructors
///
/// Constructs a new constraint on the relationship
///
/// role from which the relationship originates
/// role to which the relationship is linked/targeted to
/// properties on entity type of from role which take part in the constraint
/// properties on entity type of to role which take part in the constraint
/// Argument Null exception if any of the arguments is null
internal ReferentialConstraint(RelationshipEndMember fromRole,
RelationshipEndMember toRole,
IEnumerable fromProperties,
IEnumerable toProperties)
{
_fromRole = EntityUtil.GenericCheckArgumentNull(fromRole, "fromRole");
_toRole = EntityUtil.GenericCheckArgumentNull(toRole, "toRole");
_fromProperties = new ReadOnlyMetadataCollection(new MetadataCollection(
EntityUtil.GenericCheckArgumentNull(fromProperties, "fromProperties")));
_toProperties = new ReadOnlyMetadataCollection(new MetadataCollection(
EntityUtil.GenericCheckArgumentNull(toProperties, "toProperties")));
}
#endregion
#region Fields
private RelationshipEndMember _fromRole;
private RelationshipEndMember _toRole;
private readonly ReadOnlyMetadataCollection _fromProperties;
private readonly ReadOnlyMetadataCollection _toProperties;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.ReferentialConstraint; } }
///
/// Returns the identity for this constraint
///
internal override string Identity
{
get
{
return this.FromRole.Name + "_" + this.ToRole.Name;
}
}
///
/// Returns the FromRole which takes part in this referential constraint
///
/// Thrown if value passed into setter is null
/// Thrown if the ReferentialConstraint instance is in ReadOnly state
[MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
public RelationshipEndMember FromRole
{
get
{
return _fromRole;
}
}
///
/// Returns the ToRole which takes part in this referential constraint
///
/// Thrown if value passed into setter is null
/// Thrown if the ReferentialConstraint instance is in ReadOnly state
[MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
public RelationshipEndMember ToRole
{
get
{
return _toRole;
}
}
///
/// Returns the collection of properties on the from role on which the constraint is defined on
///
[MetadataProperty(BuiltInTypeKind.EdmProperty, true)]
public ReadOnlyMetadataCollection FromProperties
{
get
{
return _fromProperties;
}
}
///
/// Returns the collection of properties on the ToRole on whose value the constraint is defined on
///
[MetadataProperty(BuiltInTypeKind.EdmProperty, true)]
public ReadOnlyMetadataCollection ToProperties
{
get
{
return _toProperties;
}
}
#endregion
#region Methods
///
/// Overriding System.Object.ToString to provide better String representation
/// ofr this type.
///
public override string ToString()
{
return this.FromRole.Name + "_" + this.ToRole.Name;
}
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
RelationshipEndMember fromRole = FromRole;
if (fromRole != null)
{
fromRole.SetReadOnly();
}
RelationshipEndMember toRole = ToRole;
if (toRole != null)
{
toRole.SetReadOnly();
}
this.FromProperties.Source.SetReadOnly();
this.ToProperties.Source.SetReadOnly();
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
namespace System.Data.Metadata.Edm
{
///
/// This class describes referential constraint on the relationships
///
public sealed class ReferentialConstraint : MetadataItem
{
#region Constructors
///
/// Constructs a new constraint on the relationship
///
/// role from which the relationship originates
/// role to which the relationship is linked/targeted to
/// properties on entity type of from role which take part in the constraint
/// properties on entity type of to role which take part in the constraint
/// Argument Null exception if any of the arguments is null
internal ReferentialConstraint(RelationshipEndMember fromRole,
RelationshipEndMember toRole,
IEnumerable fromProperties,
IEnumerable toProperties)
{
_fromRole = EntityUtil.GenericCheckArgumentNull(fromRole, "fromRole");
_toRole = EntityUtil.GenericCheckArgumentNull(toRole, "toRole");
_fromProperties = new ReadOnlyMetadataCollection(new MetadataCollection(
EntityUtil.GenericCheckArgumentNull(fromProperties, "fromProperties")));
_toProperties = new ReadOnlyMetadataCollection(new MetadataCollection(
EntityUtil.GenericCheckArgumentNull(toProperties, "toProperties")));
}
#endregion
#region Fields
private RelationshipEndMember _fromRole;
private RelationshipEndMember _toRole;
private readonly ReadOnlyMetadataCollection _fromProperties;
private readonly ReadOnlyMetadataCollection _toProperties;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.ReferentialConstraint; } }
///
/// Returns the identity for this constraint
///
internal override string Identity
{
get
{
return this.FromRole.Name + "_" + this.ToRole.Name;
}
}
///
/// Returns the FromRole which takes part in this referential constraint
///
/// Thrown if value passed into setter is null
/// Thrown if the ReferentialConstraint instance is in ReadOnly state
[MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
public RelationshipEndMember FromRole
{
get
{
return _fromRole;
}
}
///
/// Returns the ToRole which takes part in this referential constraint
///
/// Thrown if value passed into setter is null
/// Thrown if the ReferentialConstraint instance is in ReadOnly state
[MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
public RelationshipEndMember ToRole
{
get
{
return _toRole;
}
}
///
/// Returns the collection of properties on the from role on which the constraint is defined on
///
[MetadataProperty(BuiltInTypeKind.EdmProperty, true)]
public ReadOnlyMetadataCollection FromProperties
{
get
{
return _fromProperties;
}
}
///
/// Returns the collection of properties on the ToRole on whose value the constraint is defined on
///
[MetadataProperty(BuiltInTypeKind.EdmProperty, true)]
public ReadOnlyMetadataCollection ToProperties
{
get
{
return _toProperties;
}
}
#endregion
#region Methods
///
/// Overriding System.Object.ToString to provide better String representation
/// ofr this type.
///
public override string ToString()
{
return this.FromRole.Name + "_" + this.ToRole.Name;
}
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
RelationshipEndMember fromRole = FromRole;
if (fromRole != null)
{
fromRole.SetReadOnly();
}
RelationshipEndMember toRole = ToRole;
if (toRole != null)
{
toRole.SetReadOnly();
}
this.FromProperties.Source.SetReadOnly();
this.ToProperties.Source.SetReadOnly();
}
}
#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
- XPathSingletonIterator.cs
- TCPListener.cs
- HtmlHead.cs
- QilName.cs
- RelationshipDetailsCollection.cs
- AccessViolationException.cs
- BuildProviderAppliesToAttribute.cs
- InheritedPropertyDescriptor.cs
- SplineKeyFrames.cs
- CommonDialog.cs
- TrailingSpaceComparer.cs
- ConfigXmlWhitespace.cs
- HotSpotCollection.cs
- MbpInfo.cs
- XPathDocumentBuilder.cs
- SqlProfileProvider.cs
- EdmTypeAttribute.cs
- SchemaNotation.cs
- TimelineClockCollection.cs
- Vector3DKeyFrameCollection.cs
- DataGridRowEventArgs.cs
- ConvertersCollection.cs
- DataMember.cs
- TextEditorLists.cs
- ObjectSecurity.cs
- ICollection.cs
- AppDomainUnloadedException.cs
- PrivilegedConfigurationManager.cs
- OutputBuffer.cs
- diagnosticsswitches.cs
- ImagingCache.cs
- HttpsTransportElement.cs
- EditorAttribute.cs
- HttpProfileBase.cs
- PolygonHotSpot.cs
- ModelUIElement3D.cs
- HMACSHA384.cs
- XmlArrayAttribute.cs
- ClonableStack.cs
- NonBatchDirectoryCompiler.cs
- ConfigXmlCDataSection.cs
- panel.cs
- PerformanceCounterPermissionEntryCollection.cs
- EdmFunctionAttribute.cs
- Mapping.cs
- ConstraintCollection.cs
- HttpResponseWrapper.cs
- WorkflowLayouts.cs
- Converter.cs
- RecommendedAsConfigurableAttribute.cs
- HttpConfigurationContext.cs
- ToolboxComponentsCreatedEventArgs.cs
- OleDbStruct.cs
- TableHeaderCell.cs
- HtmlForm.cs
- DataGridViewColumn.cs
- ValidationError.cs
- KeysConverter.cs
- RegexMatchCollection.cs
- HttpRequestTraceRecord.cs
- WebReferenceOptions.cs
- DataGridViewCellStyleChangedEventArgs.cs
- HttpListenerElement.cs
- WizardPanel.cs
- PrivateFontCollection.cs
- Query.cs
- ListManagerBindingsCollection.cs
- ImportException.cs
- newinstructionaction.cs
- CodeNamespaceImport.cs
- SafeNativeMethods.cs
- EdmFunction.cs
- CommandManager.cs
- InvokeMethodActivity.cs
- IssuanceLicense.cs
- XPathBinder.cs
- DispatcherExceptionEventArgs.cs
- Interlocked.cs
- XmlSchemaSubstitutionGroup.cs
- embossbitmapeffect.cs
- ScalarType.cs
- FormViewUpdatedEventArgs.cs
- XPathSelfQuery.cs
- PassportIdentity.cs
- SqlEnums.cs
- WindowManager.cs
- DropDownButton.cs
- OrCondition.cs
- RoleManagerModule.cs
- MenuCommand.cs
- JapaneseCalendar.cs
- precedingquery.cs
- BuildProviderAppliesToAttribute.cs
- URLString.cs
- XmlRawWriter.cs
- HttpCachePolicy.cs
- SafeMemoryMappedViewHandle.cs
- SizeAnimationBase.cs
- BuilderPropertyEntry.cs
- TransportSecurityProtocolFactory.cs