private IEnumerable <EfColumnInfo> DecodeComplexTypes(ComplexPropertyMapping complexMapping, Type parentClass) { //throw new NotImplementedException("We do not currently handle complex properties"); var complexCols = new List <EfColumnInfo>(); foreach (var property in complexMapping.TypeMappings.SelectMany(x => x.PropertyMappings)) { var complexClrType = Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(parentClass, complexMapping.Property.Name) .PropertyType; if (property.Property.IsComplexType) { complexCols.AddRange(DecodeComplexTypes((ComplexPropertyMapping)property, complexClrType)); } else { var columnName = ((ScalarPropertyMapping)property).Column.Name; var sqlTypeName = _tableEntitySet.ElementType.DeclaredMembers .Single(x => x.Name == columnName).TypeUsage.EdmType.Name; var clrProperty = Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(complexClrType, property.Property.Name); complexCols.Add(new EfColumnInfo(columnName, sqlTypeName, property.Property.Nullable, property.Property.MaxLength, property.Property.Precision, null, clrProperty)); } } return(complexCols); }
public List <EfColumnInfo> DecodeTableProperties(EntitySet entitySet, Type clrClassType, List <EfKeyOrder> primaryKeys) { var columnInfos = new List <EfColumnInfo>(); foreach (var edmProperty in entitySet.ElementType.DeclaredProperties) { if (edmProperty.IsComplexType) { var complexColumn = _mapping.EntityTypeMappings.Single() .Fragments.Single() .PropertyMappings.OfType <ComplexPropertyMapping>().Single(m => m.Property == edmProperty); columnInfos.AddRange(DecodeComplexTypes(complexColumn, clrClassType)); } else { //normal column var columnName = _mapping.EntityTypeMappings.Single() .Fragments.Single() .PropertyMappings.OfType <ScalarPropertyMapping>() .Single(m => m.Property == edmProperty) .Column.Name; var sqlTypeName = _tableEntitySet.ElementType.DeclaredMembers .Single(x => x.Name == columnName).TypeUsage.EdmType.Name; var clrProperty = Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(clrClassType, edmProperty.Name); var primaryKey = primaryKeys.SingleOrDefault(x => x.Name == edmProperty.Name); columnInfos.Add(new EfColumnInfo(columnName, sqlTypeName, edmProperty.Nullable, edmProperty.MaxLength, edmProperty.Precision, primaryKey, clrProperty)); } } return(columnInfos); }