internal StateManagerTypeMetadata(EdmType edmType, ObjectTypeMapping mapping) { this._typeUsage = TypeUsage.Create(edmType); this._recordInfo = new DataRecordInfo(this._typeUsage); ReadOnlyMetadataCollection <EdmProperty> properties = TypeHelpers.GetProperties(edmType); this._members = new StateManagerMemberMetadata[properties.Count]; this._objectNameToOrdinal = new Dictionary <string, int>(properties.Count); this._cLayerNameToOrdinal = new Dictionary <string, int>(properties.Count); ReadOnlyMetadataCollection <EdmMember> metadataCollection = (ReadOnlyMetadataCollection <EdmMember>)null; if (Helper.IsEntityType(edmType)) { metadataCollection = ((EntityTypeBase)edmType).KeyMembers; } for (int index = 0; index < this._members.Length; ++index) { EdmProperty memberMetadata = properties[index]; ObjectPropertyMapping memberMap = (ObjectPropertyMapping)null; if (mapping != null) { memberMap = mapping.GetPropertyMap(memberMetadata.Name); if (memberMap != null) { this._objectNameToOrdinal.Add(memberMap.ClrProperty.Name, index); } } this._cLayerNameToOrdinal.Add(memberMetadata.Name, index); this._members[index] = new StateManagerMemberMetadata(memberMap, memberMetadata, metadataCollection != null && metadataCollection.Contains((EdmMember)memberMetadata)); } }
internal StateManagerTypeMetadata(EdmType edmType, ObjectTypeMapping mapping) { DebugCheck.NotNull(edmType); Debug.Assert( Helper.IsEntityType(edmType) || Helper.IsComplexType(edmType), "not Complex or EntityType"); Debug.Assert( ReferenceEquals(mapping, null) || ReferenceEquals(mapping.EdmType, edmType), "different EdmType instance"); _typeUsage = TypeUsage.Create(edmType); _recordInfo = new DataRecordInfo(_typeUsage); var members = TypeHelpers.GetProperties(edmType); _members = new StateManagerMemberMetadata[members.Count]; _objectNameToOrdinal = new Dictionary <string, int>(members.Count); _cLayerNameToOrdinal = new Dictionary <string, int>(members.Count); ReadOnlyMetadataCollection <EdmMember> keyMembers = null; if (Helper.IsEntityType(edmType)) { keyMembers = ((EntityType)edmType).KeyMembers; } for (var i = 0; i < _members.Length; ++i) { var member = members[i]; ObjectPropertyMapping memberMap = null; if (null != mapping) { memberMap = mapping.GetPropertyMap(member.Name); if (null != memberMap) { _objectNameToOrdinal.Add(memberMap.ClrProperty.Name, i); // olayer name } } _cLayerNameToOrdinal.Add(member.Name, i); // clayer name // Determine whether this member is part of the identity of the entity. _members[i] = new StateManagerMemberMetadata(memberMap, member, ((null != keyMembers) && keyMembers.Contains(member))); } }
internal Plan(TypeUsage key, ObjectTypeMapping mapping, System.Collections.ObjectModel.ReadOnlyCollection <FieldMetadata> fields) { Debug.Assert(null != mapping, "null ObjectTypeMapping"); Debug.Assert(null != fields, "null FieldMetadata"); Key = key; Debug.Assert(!Helper.IsEntityType(mapping.ClrType), "Expecting complex type"); ClrType = LightweightCodeGenerator.GetConstructorDelegateForType((ClrComplexType)mapping.ClrType); Properties = new PlanEdmProperty[fields.Count]; int lastOrdinal = -1; for (int i = 0; i < Properties.Length; ++i) { FieldMetadata field = fields[i]; Debug.Assert(unchecked ((uint)field.Ordinal) < unchecked ((uint)fields.Count), "FieldMetadata.Ordinal out of range of Fields.Count"); Debug.Assert(lastOrdinal < field.Ordinal, "FieldMetadata.Ordinal is not increasing"); lastOrdinal = field.Ordinal; Properties[i] = new PlanEdmProperty(lastOrdinal, mapping.GetPropertyMap(field.FieldType.Name).ClrProperty); } }
internal Plan(TypeUsage key, ObjectTypeMapping mapping, ReadOnlyCollection <FieldMetadata> fields) { DebugCheck.NotNull(mapping); DebugCheck.NotNull(fields); Key = key; Debug.Assert(!Helper.IsEntityType(mapping.ClrType), "Expecting complex type"); ClrType = DelegateFactory.GetConstructorDelegateForType((ClrComplexType)mapping.ClrType); Properties = new PlanEdmProperty[fields.Count]; var lastOrdinal = -1; for (var i = 0; i < Properties.Length; ++i) { var field = fields[i]; Debug.Assert( unchecked ((uint)field.Ordinal) < unchecked ((uint)fields.Count), "FieldMetadata.Ordinal out of range of Fields.Count"); Debug.Assert(lastOrdinal < field.Ordinal, "FieldMetadata.Ordinal is not increasing"); lastOrdinal = field.Ordinal; Properties[i] = new PlanEdmProperty(lastOrdinal, mapping.GetPropertyMap(field.FieldType.Name).ClrProperty); } }
internal Plan( TypeUsage key, ObjectTypeMapping mapping, ReadOnlyCollection <FieldMetadata> fields) { this.Key = key; this.ClrType = DelegateFactory.GetConstructorDelegateForType((ClrComplexType)mapping.ClrType); this.Properties = new ComplexTypeMaterializer.PlanEdmProperty[fields.Count]; for (int index = 0; index < this.Properties.Length; ++index) { FieldMetadata field = fields[index]; int ordinal = field.Ordinal; this.Properties[index] = new ComplexTypeMaterializer.PlanEdmProperty(ordinal, mapping.GetPropertyMap(field.FieldType.Name).ClrProperty); } }