Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / EntityRecordInfo.cs / 1305376 / EntityRecordInfo.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.Common {
using System.Data;
using System.Collections.Generic;
using System.Data.Metadata.Edm;
using System.Diagnostics;
///
/// EntityRecordInfo class providing a simple way to access both the type information and the column information.
///
public class EntityRecordInfo : DataRecordInfo {
private readonly EntityKey _entityKey;
private readonly EntitySet _entitySet;
///
///
///
///
///
///
public EntityRecordInfo(EntityType metadata, IEnumerable memberInfo, EntityKey entityKey, EntitySet entitySet)
: base(TypeUsage.Create(metadata), memberInfo) {
EntityUtil.CheckArgumentNull(entityKey, "entityKey");
EntityUtil.CheckArgumentNull(entitySet, "entitySet");
_entityKey = entityKey;
_entitySet = entitySet;
ValidateEntityType(entitySet);
}
///
///
///
///
///
internal EntityRecordInfo(EntityType metadata, EntityKey entityKey, EntitySet entitySet)
: base(TypeUsage.Create(metadata)) {
EntityUtil.CheckArgumentNull(entityKey, "entityKey");
_entityKey = entityKey;
_entitySet = entitySet;
#if DEBUG
try
{
ValidateEntityType(entitySet);
}
catch
{
Debug.Assert(false, "should always be valid EntityType when internally constructed");
throw;
}
#endif
}
///
/// Reusing TypeUsage and FieldMetadata from another EntityRecordInfo which has all the same info
/// but with a different EntityKey instance.
///
internal EntityRecordInfo(DataRecordInfo info, EntityKey entityKey, EntitySet entitySet)
: base(info)
{
_entityKey = entityKey;
_entitySet = entitySet;
#if DEBUG
try
{
ValidateEntityType(entitySet);
}
catch
{
Debug.Assert(false, "should always be valid EntityType when internally constructed");
throw;
}
#endif
}
///
/// the EntityKey
///
public EntityKey EntityKey {
get {
return _entityKey;
}
}
// using EntitySetBase versus EntitySet prevents the unnecessary cast of ElementType to EntityType
private void ValidateEntityType(EntitySetBase entitySet)
{
if (!object.ReferenceEquals(RecordType.EdmType, null) &&
!object.ReferenceEquals(_entityKey, EntityKey.EntityNotValidKey) &&
!object.ReferenceEquals(_entityKey, EntityKey.NoEntitySetKey) &&
!object.ReferenceEquals(RecordType.EdmType, entitySet.ElementType) &&
!entitySet.ElementType.IsBaseTypeOf(RecordType.EdmType))
{
throw EntityUtil.Argument(System.Data.Entity.Strings.EntityTypesDoNotAgree);
}
}
}
}
// 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
- XmlSchemaSet.cs
- ExpressionSelection.cs
- IsolatedStorageFile.cs
- HttpDictionary.cs
- QuaternionAnimationUsingKeyFrames.cs
- SerializationFieldInfo.cs
- SimpleTableProvider.cs
- SQLInt16.cs
- UriSection.cs
- SingletonChannelAcceptor.cs
- ListViewInsertedEventArgs.cs
- OperationGenerator.cs
- ClientConvert.cs
- ZipFileInfo.cs
- ToolStripItemTextRenderEventArgs.cs
- dataobject.cs
- ToolBarOverflowPanel.cs
- GeneralTransformGroup.cs
- FocusWithinProperty.cs
- ParallelTimeline.cs
- ExtendedPropertyInfo.cs
- SQLInt16Storage.cs
- TemplateControlCodeDomTreeGenerator.cs
- UpdateProgress.cs
- UrlMappingsSection.cs
- ExceptionUtil.cs
- PropertyGridView.cs
- Visual3D.cs
- ThreadExceptionDialog.cs
- TextHintingModeValidation.cs
- ItemsChangedEventArgs.cs
- OleServicesContext.cs
- OdbcTransaction.cs
- ServiceCredentials.cs
- WmlTextViewAdapter.cs
- WizardStepBase.cs
- X509CertificateTrustedIssuerElementCollection.cs
- PageHandlerFactory.cs
- VarRemapper.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- CroppedBitmap.cs
- TimeoutHelper.cs
- XamlFxTrace.cs
- EmptyImpersonationContext.cs
- KeyMatchBuilder.cs
- ListBoxItemAutomationPeer.cs
- DbXmlEnabledProviderManifest.cs
- FormatterServicesNoSerializableCheck.cs
- ExtensionFile.cs
- Drawing.cs
- BitmapSourceSafeMILHandle.cs
- BitmapSizeOptions.cs
- ConfigurationProperty.cs
- AsyncPostBackErrorEventArgs.cs
- PageContent.cs
- ToggleProviderWrapper.cs
- MergeFailedEvent.cs
- _TransmitFileOverlappedAsyncResult.cs
- DiscoveryReference.cs
- OletxTransactionHeader.cs
- SqlConnectionFactory.cs
- StateFinalizationDesigner.cs
- ToolStripSplitButton.cs
- Confirm.cs
- RoleServiceManager.cs
- DrawingImage.cs
- UTF8Encoding.cs
- ILGen.cs
- RouteItem.cs
- XmlBinaryReader.cs
- OpCellTreeNode.cs
- Parser.cs
- StrokeIntersection.cs
- CompilerCollection.cs
- SerializationException.cs
- Connection.cs
- StateDesigner.TransitionInfo.cs
- FileUpload.cs
- ModelItemExtensions.cs
- InplaceBitmapMetadataWriter.cs
- WebPartMovingEventArgs.cs
- FixedSOMLineRanges.cs
- OperationInvokerTrace.cs
- SQLInt32.cs
- BinaryReader.cs
- TextTreeUndoUnit.cs
- TextServicesCompartment.cs
- SoapFormatterSinks.cs
- FormatVersion.cs
- SqlExpressionNullability.cs
- SamlAuthenticationStatement.cs
- ScaleTransform.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ThrowHelper.cs
- NameGenerator.cs
- NodeLabelEditEvent.cs
- SecurityManager.cs
- SessionStateSection.cs
- InvalidOperationException.cs
- NumberFunctions.cs