Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Common / EntityRecordInfo.cs / 2 / 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.
//------------------------------------------------------------------------------
//
// 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
- DataServiceRequestOfT.cs
- GridEntryCollection.cs
- DesignTimeTemplateParser.cs
- CmsInterop.cs
- DataRelationPropertyDescriptor.cs
- ContainerControl.cs
- KeyGesture.cs
- EventSinkActivity.cs
- XmlObjectSerializerWriteContext.cs
- TemplateLookupAction.cs
- DispatchWrapper.cs
- SqlServer2KCompatibilityCheck.cs
- OdbcConnection.cs
- CqlErrorHelper.cs
- SecurityUtils.cs
- ScrollPattern.cs
- ContainerFilterService.cs
- CustomErrorsSection.cs
- ConsumerConnectionPointCollection.cs
- AddressingProperty.cs
- XmlSchemaObjectTable.cs
- SafeHandle.cs
- EntityDataSourceDataSelectionPanel.cs
- GridViewColumnHeader.cs
- SQLMembershipProvider.cs
- TextControlDesigner.cs
- ConfigurationConverterBase.cs
- SimpleBitVector32.cs
- TagPrefixCollection.cs
- Highlights.cs
- SequenceDesigner.cs
- StubHelpers.cs
- ScrollViewerAutomationPeer.cs
- RepeatBehavior.cs
- PolicyStatement.cs
- QilXmlReader.cs
- HtmlInputImage.cs
- ListViewItemMouseHoverEvent.cs
- InheritedPropertyChangedEventArgs.cs
- HtmlContainerControl.cs
- AuthorizationSection.cs
- WebPartTransformerCollection.cs
- FixedSOMLineCollection.cs
- FieldNameLookup.cs
- DummyDataSource.cs
- CodeDelegateCreateExpression.cs
- FormViewActionList.cs
- FileDetails.cs
- MDIWindowDialog.cs
- EdmScalarPropertyAttribute.cs
- ViewDesigner.cs
- FixedTextView.cs
- QueryCacheKey.cs
- SessionEndingEventArgs.cs
- RequestCacheManager.cs
- CodeObject.cs
- indexingfiltermarshaler.cs
- GZipStream.cs
- RegexReplacement.cs
- VectorAnimation.cs
- SQLDouble.cs
- InvalidateEvent.cs
- RegexFCD.cs
- Site.cs
- ModuleBuilder.cs
- TransformerInfo.cs
- ISAPIRuntime.cs
- SafeFindHandle.cs
- SqlDependency.cs
- DataDocumentXPathNavigator.cs
- TrackingParticipant.cs
- ObjectDataSourceEventArgs.cs
- TemplatePartAttribute.cs
- AdornedElementPlaceholder.cs
- EventSetterHandlerConverter.cs
- ILGenerator.cs
- TcpTransportManager.cs
- ReferencedCollectionType.cs
- UseAttributeSetsAction.cs
- _SSPIWrapper.cs
- LocatorPart.cs
- FtpWebResponse.cs
- HttpConfigurationContext.cs
- SuspendDesigner.cs
- DataTablePropertyDescriptor.cs
- XmlWrappingWriter.cs
- FormsAuthenticationTicket.cs
- ItemChangedEventArgs.cs
- WorkflowServiceHost.cs
- Point3DKeyFrameCollection.cs
- DataObjectMethodAttribute.cs
- CustomAttributeBuilder.cs
- XmlQualifiedNameTest.cs
- ServiceHttpModule.cs
- CodeIdentifier.cs
- Task.cs
- GradientStop.cs
- ToolboxItemCollection.cs
- BinaryMethodMessage.cs
- Util.cs