Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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, 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
- OneOfElement.cs
- ListViewDataItem.cs
- DataTableNewRowEvent.cs
- ToolStripItemEventArgs.cs
- ModifiableIteratorCollection.cs
- SlotInfo.cs
- UnsafePeerToPeerMethods.cs
- SessionEndingCancelEventArgs.cs
- codemethodreferenceexpression.cs
- WS2007HttpBindingCollectionElement.cs
- XPathBinder.cs
- ThumbAutomationPeer.cs
- ElementNotEnabledException.cs
- InstancePersistenceException.cs
- mda.cs
- HtmlFormWrapper.cs
- XmlDocumentSurrogate.cs
- MimeMultiPart.cs
- AbstractSvcMapFileLoader.cs
- FormsAuthentication.cs
- TransformerInfoCollection.cs
- ListBase.cs
- ImageAnimator.cs
- DataRelation.cs
- CodeExpressionCollection.cs
- _Rfc2616CacheValidators.cs
- URL.cs
- ConfigurationElementCollection.cs
- TimeSpanOrInfiniteConverter.cs
- WSSecureConversationDec2005.cs
- PropertyDescriptorGridEntry.cs
- CultureData.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- DesignerCommandSet.cs
- TextTreePropertyUndoUnit.cs
- CheckBoxPopupAdapter.cs
- DataContext.cs
- ToolStripSystemRenderer.cs
- StringPropertyBuilder.cs
- SoapObjectReader.cs
- CoTaskMemUnicodeSafeHandle.cs
- MetadataSerializer.cs
- UpDownEvent.cs
- AQNBuilder.cs
- SectionVisual.cs
- Size.cs
- BufferedGraphicsManager.cs
- XmlMemberMapping.cs
- httpserverutility.cs
- QueryCacheKey.cs
- DataGridViewBindingCompleteEventArgs.cs
- DataContext.cs
- SqlUserDefinedTypeAttribute.cs
- WorkItem.cs
- RecognizedPhrase.cs
- PrintPageEvent.cs
- SqlDependency.cs
- TreeViewHitTestInfo.cs
- DesignObjectWrapper.cs
- CngUIPolicy.cs
- Buffer.cs
- RoleManagerSection.cs
- ViewGenerator.cs
- RadioButtonAutomationPeer.cs
- XmlStringTable.cs
- EntityDesignerBuildProvider.cs
- SrgsGrammar.cs
- RuleAction.cs
- LassoSelectionBehavior.cs
- JoinElimination.cs
- StringFormat.cs
- ExeContext.cs
- ComplexObject.cs
- MarkupExtensionParser.cs
- XsdValidatingReader.cs
- ThreadStaticAttribute.cs
- GridViewColumnCollectionChangedEventArgs.cs
- RubberbandSelector.cs
- DefaultPropertyAttribute.cs
- TriState.cs
- OutputChannelBinder.cs
- DbProviderFactoriesConfigurationHandler.cs
- OperationAbortedException.cs
- DataSourceProvider.cs
- NumericUpDownAcceleration.cs
- DiscardableAttribute.cs
- PreloadedPackages.cs
- SocketElement.cs
- TextBreakpoint.cs
- XmlAttributeOverrides.cs
- TypedReference.cs
- HTTPNotFoundHandler.cs
- dsa.cs
- SingleObjectCollection.cs
- RangeValuePattern.cs
- NativeMethods.cs
- SimpleHandlerBuildProvider.cs
- SurrogateEncoder.cs
- MarkupCompilePass2.cs
- ControlTemplate.cs