Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / DataRecordInfo.cs / 1305376 / DataRecordInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.Common { using System.Data; using System.Collections; using System.Collections.Generic; using System.Data.Metadata.Edm; using System.Diagnostics; ////// DataRecordInfo class providing a simple way to access both the type information and the column information. /// public class DataRecordInfo { private readonly System.Collections.ObjectModel.ReadOnlyCollection_fieldMetadata; private readonly TypeUsage _metadata; /// /// Construct DataRecordInfo with list of EdmMembers. /// Each memberInfo must be a member of metadata. /// /// /// public DataRecordInfo(TypeUsage metadata, IEnumerablememberInfo) { EntityUtil.CheckArgumentNull(metadata, "metadata"); IBaseList members = TypeHelpers.GetAllStructuralMembers(metadata.EdmType); List fieldList = new List (members.Count); if (null != memberInfo) { foreach (EdmMember member in memberInfo) { if ((null != member) && (0 <= members.IndexOf(member)) && ((BuiltInTypeKind.EdmProperty == member.BuiltInTypeKind) || // for ComplexType, EntityType; BuiltTypeKind.NaviationProperty not allowed (BuiltInTypeKind.AssociationEndMember == member.BuiltInTypeKind))) // for AssociationType { // each memberInfo must be non-null and be part of Properties or AssociationEndMembers //validate that EdmMembers are from the same type or base type of the passed in metadata. if((member.DeclaringType != metadata.EdmType) && !member.DeclaringType.IsBaseTypeOf(metadata.EdmType)) { throw EntityUtil.Argument(System.Data.Entity.Strings.EdmMembersDefiningTypeDoNotAgreeWithMetadataType); } fieldList.Add(new FieldMetadata(fieldList.Count, member)); } else { // expecting empty memberInfo for non-structural && non-null member part of members if structural throw EntityUtil.Argument("memberInfo"); } } } // expecting structural types to have something at least 1 property // (((null == structural) && (0 == fieldList.Count)) || ((null != structural) && (0 < fieldList.Count))) if (Helper.IsStructuralType(metadata.EdmType) == (0 < fieldList.Count)) { _fieldMetadata = new System.Collections.ObjectModel.ReadOnlyCollection (fieldList); _metadata = metadata; } else { throw EntityUtil.Argument("memberInfo"); } } /// /// Construct FieldMetadata for structuralType.Members from TypeUsage /// internal DataRecordInfo(TypeUsage metadata) { Debug.Assert(null != metadata, "invalid attempt to instantiate DataRecordInfo with null metadata information"); IBaseListstructuralMembers = TypeHelpers.GetAllStructuralMembers(metadata); FieldMetadata[] fieldList = new FieldMetadata[structuralMembers.Count]; for (int i = 0; i < fieldList.Length; ++i) { EdmMember member = structuralMembers[i]; Debug.Assert((BuiltInTypeKind.EdmProperty == member.BuiltInTypeKind) || (BuiltInTypeKind.AssociationEndMember == member.BuiltInTypeKind), "unexpected BuiltInTypeKind for member"); fieldList[i] = new FieldMetadata(i, member); } _fieldMetadata = new System.Collections.ObjectModel.ReadOnlyCollection (fieldList); _metadata = metadata; } /// /// Reusing TypeUsage and FieldMetadata from another EntityRecordInfo which has all the same info /// but with a different EntityKey instance. /// internal DataRecordInfo(DataRecordInfo recordInfo) { _fieldMetadata = recordInfo._fieldMetadata; _metadata = recordInfo._metadata; } ////// Column information. /// public System.Collections.ObjectModel.ReadOnlyCollectionFieldMetadata { get { return _fieldMetadata; } } /// /// Type information. /// public TypeUsage RecordType { get { return _metadata; } } } } // 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
- RootProfilePropertySettingsCollection.cs
- DebugView.cs
- SQlBooleanStorage.cs
- IISUnsafeMethods.cs
- DbParameterCollectionHelper.cs
- ResolveMatchesMessage11.cs
- MasterPage.cs
- AssemblyBuilder.cs
- WebContext.cs
- PageAsyncTask.cs
- CapabilitiesRule.cs
- StringAnimationUsingKeyFrames.cs
- KeyValueInternalCollection.cs
- HealthMonitoringSectionHelper.cs
- ProfilePropertySettings.cs
- ScrollPattern.cs
- AppDomainFactory.cs
- PolicyManager.cs
- X509SecurityToken.cs
- XmlSerializerFactory.cs
- GeometryValueSerializer.cs
- TextRangeProviderWrapper.cs
- UiaCoreApi.cs
- HttpListenerContext.cs
- ExchangeUtilities.cs
- BrowserCapabilitiesCodeGenerator.cs
- ServiceObjectContainer.cs
- IntSecurity.cs
- WebBodyFormatMessageProperty.cs
- GeneralTransform2DTo3DTo2D.cs
- XmlQueryRuntime.cs
- ImageMetadata.cs
- SafeCryptContextHandle.cs
- HtmlInputControl.cs
- MediaContext.cs
- ServiceNameElementCollection.cs
- ListViewHitTestInfo.cs
- BitmapEffectGeneralTransform.cs
- LockingPersistenceProvider.cs
- ButtonRenderer.cs
- DelayedRegex.cs
- TableCell.cs
- Html32TextWriter.cs
- Byte.cs
- SchemaNotation.cs
- SystemSounds.cs
- ValueChangedEventManager.cs
- DataGridViewComboBoxEditingControl.cs
- DeadCharTextComposition.cs
- TableCell.cs
- PropertyToken.cs
- TemplateBuilder.cs
- Point4D.cs
- AssemblyBuilder.cs
- TraceHwndHost.cs
- DependencyPropertyKey.cs
- RecordManager.cs
- TabletDevice.cs
- RawStylusActions.cs
- ListControl.cs
- XMLDiffLoader.cs
- BamlBinaryWriter.cs
- UnauthorizedWebPart.cs
- DefaultHttpHandler.cs
- ProtectedConfigurationSection.cs
- InvalidPropValue.cs
- Metadata.cs
- CodeAccessPermission.cs
- SrgsSemanticInterpretationTag.cs
- ClientSponsor.cs
- SourceElementsCollection.cs
- ClientSettingsSection.cs
- UndoManager.cs
- _BaseOverlappedAsyncResult.cs
- DataBoundControlHelper.cs
- ModelPropertyCollectionImpl.cs
- HttpPostServerProtocol.cs
- DataGridBoolColumn.cs
- SHA256Managed.cs
- PageEventArgs.cs
- NativeMethods.cs
- TimeEnumHelper.cs
- XmlChildEnumerator.cs
- ConsoleEntryPoint.cs
- DbProviderFactory.cs
- Membership.cs
- ConnectionPoint.cs
- FontNamesConverter.cs
- KeyGesture.cs
- WpfKnownMemberInvoker.cs
- ActivityStateQuery.cs
- DataRowView.cs
- ActiveXContainer.cs
- Scene3D.cs
- RadioButton.cs
- Soap.cs
- WebPartDisplayModeCancelEventArgs.cs
- BinaryKeyIdentifierClause.cs
- EnlistmentTraceIdentifier.cs
- StateChangeEvent.cs