Code:
/ 4.0 / 4.0 / 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, IEnumerablememberInfo, 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, IEnumerablememberInfo, 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
- PropertyEmitter.cs
- SHA1CryptoServiceProvider.cs
- SiteMap.cs
- CommentAction.cs
- PopupRoot.cs
- BaseDataListComponentEditor.cs
- Bezier.cs
- BuiltInExpr.cs
- PublisherMembershipCondition.cs
- TextTreeNode.cs
- RuntimeConfigurationRecord.cs
- ResourceCategoryAttribute.cs
- Int32.cs
- XPathExpr.cs
- Converter.cs
- DeferredTextReference.cs
- PreloadedPackages.cs
- LocationUpdates.cs
- TextTreeText.cs
- FileReader.cs
- SqlBooleanMismatchVisitor.cs
- ScrollBar.cs
- SafeSystemMetrics.cs
- Menu.cs
- JsonGlobals.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- SoapServerMethod.cs
- DataServiceHostFactory.cs
- PerspectiveCamera.cs
- Calendar.cs
- RootBuilder.cs
- NotImplementedException.cs
- DesignerDataStoredProcedure.cs
- RMEnrollmentPage3.cs
- MailDefinition.cs
- ReliableChannelListener.cs
- DataGridViewCellParsingEventArgs.cs
- DataShape.cs
- ListViewGroupConverter.cs
- CustomCredentialPolicy.cs
- MetadataArtifactLoaderCompositeResource.cs
- ProvidePropertyAttribute.cs
- Array.cs
- ToolboxComponentsCreatingEventArgs.cs
- SuppressMergeCheckAttribute.cs
- XmlDataSourceView.cs
- DesignerActionTextItem.cs
- XsltContext.cs
- Compiler.cs
- ContextCorrelationInitializer.cs
- mansign.cs
- ConfigurationSectionCollection.cs
- WinFormsSecurity.cs
- KernelTypeValidation.cs
- AxImporter.cs
- Rect3DValueSerializer.cs
- ValidationResult.cs
- WebPartZone.cs
- Privilege.cs
- ProcessHostServerConfig.cs
- MatrixTransform3D.cs
- ExpressionBuilderContext.cs
- PublisherMembershipCondition.cs
- FirstMatchCodeGroup.cs
- WindowsStatusBar.cs
- EventToken.cs
- XmlNamespaceManager.cs
- SafeArrayTypeMismatchException.cs
- ArglessEventHandlerProxy.cs
- ListViewGroup.cs
- StringWriter.cs
- ServiceMemoryGates.cs
- EntityCommandExecutionException.cs
- ProcessStartInfo.cs
- StylusPointPropertyId.cs
- Privilege.cs
- HttpHandlerActionCollection.cs
- Clock.cs
- ImageIndexConverter.cs
- TraceSwitch.cs
- ManifestSignatureInformation.cs
- HttpBrowserCapabilitiesWrapper.cs
- SqlTypesSchemaImporter.cs
- sqlnorm.cs
- FunctionImportElement.cs
- SamlAuthorizationDecisionClaimResource.cs
- JpegBitmapDecoder.cs
- ParameterElement.cs
- UnsafeNativeMethods.cs
- NonParentingControl.cs
- ViewGenerator.cs
- WebConvert.cs
- EventSetterHandlerConverter.cs
- DefaultHttpHandler.cs
- UITypeEditors.cs
- XmlSchemaSimpleTypeList.cs
- TemplateControlBuildProvider.cs
- ExtensionFile.cs
- _RequestCacheProtocol.cs
- TextElementEnumerator.cs