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 / Map / ViewGeneration / Validation / ExtentKey.cs / 1 / ExtentKey.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Data.Metadata.Edm;
namespace System.Data.Mapping.ViewGeneration.Structures {
// This class represents the key of constraint on values that a relation slot may have
internal class ExtentKey : InternalBase {
#region Constructors
// effects: Creates a key object for an extent (present in each MemberPath)
// with the fields corresponding to keyFields
internal ExtentKey(IEnumerable keyFields) {
m_keyFields = new List(keyFields);
}
#endregion
#region Fields
// All the key fields in an entity set
private List m_keyFields;
#endregion
#region Properties
internal IEnumerable KeyFields {
get { return m_keyFields; }
}
#endregion
#region Methods
// effects: Determines all the keys (unique and primary for
// entityType) for entityType and returns a key. "prefix" gives the
// path of the extent or end of a relationship in a relationship set
// -- prefix is prepended to the entity's key fields to get the full memberpath
internal static List GetKeysForEntityType(MemberPath prefix, EntityType entityType) {
// CHANGE_[....]_MULTIPLE_KEYS: currently there is a single key only. Need to support
// keys inside complex types + unique keys
ExtentKey key = GetPrimaryKeyForEntityType(prefix, entityType);
List keys = new List();
keys.Add(key);
return keys;
}
// effects: Returns the key for entityType prefixed with prefix (for
// its memberPath)
internal static ExtentKey GetPrimaryKeyForEntityType(MemberPath prefix, EntityType entityType) {
List keyFields = new List();
foreach (EdmMember keyMember in entityType.KeyMembers) {
Debug.Assert(keyMember != null, "Bogus key member in metadata");
keyFields.Add(new MemberPath(prefix, keyMember));
}
// Just have one key for now
ExtentKey key = new ExtentKey(keyFields);
return key;
}
// effects: Returns a key correspnding to all the fields in different
// ends of relationtype prefixed with "prefix"
internal static ExtentKey GetKeyForRelationType(MemberPath prefix, AssociationType relationType) {
List keyFields = new List();
foreach (AssociationEndMember endMember in relationType.AssociationEndMembers) {
MemberPath endPrefix = new MemberPath(prefix, endMember);
EntityType entityType = MetadataHelper.GetEntityTypeForEnd(endMember);
ExtentKey primaryKey = GetPrimaryKeyForEntityType(endPrefix, entityType);
keyFields.AddRange(primaryKey.KeyFields);
}
ExtentKey key = new ExtentKey(keyFields);
return key;
}
internal string ToUserString() {
string result = StringUtil.ToCommaSeparatedStringSorted(m_keyFields);
return result;
}
internal override void ToCompactString(StringBuilder builder) {
StringUtil.ToCommaSeparatedStringSorted(builder, m_keyFields);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Data.Metadata.Edm;
namespace System.Data.Mapping.ViewGeneration.Structures {
// This class represents the key of constraint on values that a relation slot may have
internal class ExtentKey : InternalBase {
#region Constructors
// effects: Creates a key object for an extent (present in each MemberPath)
// with the fields corresponding to keyFields
internal ExtentKey(IEnumerable keyFields) {
m_keyFields = new List(keyFields);
}
#endregion
#region Fields
// All the key fields in an entity set
private List m_keyFields;
#endregion
#region Properties
internal IEnumerable KeyFields {
get { return m_keyFields; }
}
#endregion
#region Methods
// effects: Determines all the keys (unique and primary for
// entityType) for entityType and returns a key. "prefix" gives the
// path of the extent or end of a relationship in a relationship set
// -- prefix is prepended to the entity's key fields to get the full memberpath
internal static List GetKeysForEntityType(MemberPath prefix, EntityType entityType) {
// CHANGE_[....]_MULTIPLE_KEYS: currently there is a single key only. Need to support
// keys inside complex types + unique keys
ExtentKey key = GetPrimaryKeyForEntityType(prefix, entityType);
List keys = new List();
keys.Add(key);
return keys;
}
// effects: Returns the key for entityType prefixed with prefix (for
// its memberPath)
internal static ExtentKey GetPrimaryKeyForEntityType(MemberPath prefix, EntityType entityType) {
List keyFields = new List();
foreach (EdmMember keyMember in entityType.KeyMembers) {
Debug.Assert(keyMember != null, "Bogus key member in metadata");
keyFields.Add(new MemberPath(prefix, keyMember));
}
// Just have one key for now
ExtentKey key = new ExtentKey(keyFields);
return key;
}
// effects: Returns a key correspnding to all the fields in different
// ends of relationtype prefixed with "prefix"
internal static ExtentKey GetKeyForRelationType(MemberPath prefix, AssociationType relationType) {
List keyFields = new List();
foreach (AssociationEndMember endMember in relationType.AssociationEndMembers) {
MemberPath endPrefix = new MemberPath(prefix, endMember);
EntityType entityType = MetadataHelper.GetEntityTypeForEnd(endMember);
ExtentKey primaryKey = GetPrimaryKeyForEntityType(endPrefix, entityType);
keyFields.AddRange(primaryKey.KeyFields);
}
ExtentKey key = new ExtentKey(keyFields);
return key;
}
internal string ToUserString() {
string result = StringUtil.ToCommaSeparatedStringSorted(m_keyFields);
return result;
}
internal override void ToCompactString(StringBuilder builder) {
StringUtil.ToCommaSeparatedStringSorted(builder, m_keyFields);
}
#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
- Token.cs
- PeerTransportListenAddressValidator.cs
- ISessionStateStore.cs
- ControlParameter.cs
- IPGlobalProperties.cs
- FixedSOMTextRun.cs
- QilGenerator.cs
- NetworkInformationException.cs
- URLAttribute.cs
- DataSourceXmlSerializer.cs
- ReadOnlyDictionary.cs
- ComplexTypeEmitter.cs
- SqlConnectionPoolProviderInfo.cs
- XPathNodeIterator.cs
- PersonalizationProvider.cs
- Point3DCollectionConverter.cs
- GlobalEventManager.cs
- DelegatingChannelListener.cs
- HttpListenerPrefixCollection.cs
- CompiledQueryCacheEntry.cs
- TemplateInstanceAttribute.cs
- iisPickupDirectory.cs
- SoapUnknownHeader.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- WebPartManager.cs
- PenLineCapValidation.cs
- StatusBarAutomationPeer.cs
- DetailsViewModeEventArgs.cs
- EditorBrowsableAttribute.cs
- FaultPropagationQuery.cs
- ProcessHostConfigUtils.cs
- _NestedSingleAsyncResult.cs
- Panel.cs
- DefaultTextStore.cs
- _NegoStream.cs
- StringValueConverter.cs
- ToolboxComponentsCreatingEventArgs.cs
- ContextDataSourceContextData.cs
- PointAnimationUsingKeyFrames.cs
- GregorianCalendar.cs
- BufferAllocator.cs
- CodeRemoveEventStatement.cs
- HostProtectionPermission.cs
- EntityCommandExecutionException.cs
- CodeAttributeDeclarationCollection.cs
- securitycriticaldata.cs
- RectangleGeometry.cs
- AssemblyNameProxy.cs
- UnknownBitmapDecoder.cs
- TreeViewItem.cs
- PersonalizationProvider.cs
- TextRangeAdaptor.cs
- BorderGapMaskConverter.cs
- OutputCacheSection.cs
- TranslateTransform.cs
- Point3DAnimationUsingKeyFrames.cs
- PerformanceCounterLib.cs
- SessionSwitchEventArgs.cs
- Main.cs
- UrlMappingCollection.cs
- ItemsPanelTemplate.cs
- ParsedAttributeCollection.cs
- UInt32Storage.cs
- Error.cs
- TextStore.cs
- UInt32Converter.cs
- Int16Converter.cs
- QilGenerator.cs
- SqlFacetAttribute.cs
- ConfigurationStrings.cs
- ClassicBorderDecorator.cs
- DirectoryNotFoundException.cs
- BevelBitmapEffect.cs
- AnnotationMap.cs
- WebResourceUtil.cs
- LambdaCompiler.Binary.cs
- Tablet.cs
- MultiAsyncResult.cs
- RemoteX509Token.cs
- PolyLineSegmentFigureLogic.cs
- DataKeyArray.cs
- TcpStreams.cs
- NewArray.cs
- SmiXetterAccessMap.cs
- DataGridrowEditEndingEventArgs.cs
- CalendarDateRange.cs
- TableRow.cs
- XmlEncoding.cs
- XmlSerializationGeneratedCode.cs
- ContainerSelectorBehavior.cs
- NameValuePermission.cs
- TextEditorMouse.cs
- HttpClientCertificate.cs
- SecurityPolicySection.cs
- SymmetricAlgorithm.cs
- DiscoveryDocumentReference.cs
- ImageClickEventArgs.cs
- EnlistmentTraceIdentifier.cs
- MemoryResponseElement.cs
- MeshGeometry3D.cs