private void MapStructuralProperty(StructuralTypeConfiguration type, PropertyInfo property, PropertyKind propertyKind, bool isCollection) { Contract.Assert(type != null); Contract.Assert(property != null); Contract.Assert(propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Enum); bool addedExplicitly = type.Properties.Any(p => p.PropertyInfo.Name == property.Name); PropertyConfiguration addedEdmProperty; if (!isCollection) { if (propertyKind == PropertyKind.Primitive) { addedEdmProperty = type.AddProperty(property); } else if (propertyKind == PropertyKind.Enum) { AddEnumType(TypeHelper.GetUnderlyingTypeOrSelf(property.PropertyType)); addedEdmProperty = type.AddEnumProperty(property); } else { addedEdmProperty = type.AddComplexProperty(property); } } else { if (_isQueryCompositionMode) { Contract.Assert(propertyKind != PropertyKind.Complex, "we don't create complex types in query composition mode."); } if (TypeHelper.IsGenericType(property.PropertyType)) { Type elementType = property.PropertyType.GetGenericArguments().First(); Type elementUnderlyingTypeOrSelf = TypeHelper.GetUnderlyingTypeOrSelf(elementType); if (TypeHelper.IsEnum(elementUnderlyingTypeOrSelf)) { AddEnumType(elementUnderlyingTypeOrSelf); } } else { Type elementType; if (TypeHelper.IsCollection(property.PropertyType, out elementType)) { Type elementUnderlyingTypeOrSelf = TypeHelper.GetUnderlyingTypeOrSelf(elementType); if (TypeHelper.IsEnum(elementUnderlyingTypeOrSelf)) { AddEnumType(elementUnderlyingTypeOrSelf); } } } addedEdmProperty = type.AddCollectionProperty(property); } addedEdmProperty.AddedExplicitly = addedExplicitly; }