src/Misc/EFTools/EntityDesign/UI/ViewModels/MappingDetails/FunctionImport/MappingFunctionImport.cs
// <summary>
//     Returns list of MappingFunctionImportScalarProperty for each Property from the ReturnType of the FunctionImport
// </summary>
Returns list of MappingFunctionImportScalarProperty for each Property from the ReturnType of the FunctionImport
Returns list of MappingFunctionImportScalarProperty for each Property from the ReturnType of the FunctionImport
internal IList<MappingFunctionImportScalarProperty> GetScalarProperties()
        {
            var mappingScalarProperties = new List<MappingFunctionImportScalarProperty>();
            var fi = FunctionImportMapping.FunctionImportName.Target;
            Debug.Assert(fi != null, "No binding to FunctionImport found");
            if (fi != null)
            {
                ComplexType complexType = null;
                EntityType entityType = null;
                if (fi.IsReturnTypeEntityType)
                {
                    entityType = fi.ReturnTypeAsEntityType.Target;
                }
                else if (fi.IsReturnTypeComplexType
                         && fi.ReturnTypeAsComplexType.Target != null)
                {
                    complexType = fi.ReturnTypeAsComplexType.Target;
                }
                Debug.Assert(entityType != null || complexType != null, "Couldn't find FunctionImport return type");
                if (entityType != null
                    || complexType != null)
                {
                    FunctionImportTypeMapping typeMapping = null;
                    if (FunctionImportMapping.ResultMapping != null)
                    {
                        typeMapping = entityType != null
                                          ? FunctionImportMapping.ResultMapping.FindTypeMapping(entityType)
                                          : FunctionImportMapping.ResultMapping.FindTypeMapping(complexType);
                    }
                    var properties = entityType != null ? entityType.Properties() : complexType.Properties();
                    foreach (var property in properties)
                    {
                        if (typeMapping != null)
                        {
                            var scalarProperty = typeMapping.FindScalarProperty(property);
                            if (scalarProperty != null)
                            {
                                mappingScalarProperties.Add(new MappingFunctionImportScalarProperty(_context, scalarProperty, this));
                                continue;
                            }
                        }
                        mappingScalarProperties.Add(new MappingFunctionImportScalarProperty(_context, property, this));
                    }
                }
            }
            return mappingScalarProperties;
        }
internal IList < MappingFunctionImportScalarProperty > GetScalarProperties ( ) { var mappingScalarProperties = new List < MappingFunctionImportScalarProperty > ( ) ; var fi = FunctionImportMapping . FunctionImportName . Target ; Debug . Assert ( fi != null , " " ) ; if ( fi != null ) { ComplexType complexType = null ; EntityType entityType = null ; if ( fi . IsReturnTypeEntityType ) { entityType = fi . ReturnTypeAsEntityType . Target ; } else if ( fi . IsReturnTypeComplexType && fi . ReturnTypeAsComplexType . Target != null ) { complexType = fi . ReturnTypeAsComplexType . Target ; } Debug . Assert ( entityType != null || complexType != null , " " ) ; if ( entityType != null || complexType != null ) { FunctionImportTypeMapping typeMapping = null ; if ( FunctionImportMapping . ResultMapping != null ) { typeMapping = entityType != null ? FunctionImportMapping . ResultMapping . FindTypeMapping ( entityType ) : FunctionImportMapping . ResultMapping . FindTypeMapping ( complexType ) ; } var properties = entityType != null ? entityType . Properties ( ) : complexType . Properties ( ) ; foreach ( var property in properties ) { if ( typeMapping != null ) { var scalarProperty = typeMapping . FindScalarProperty ( property ) ; if ( scalarProperty != null ) { mappingScalarProperties . Add ( new MappingFunctionImportScalarProperty ( _context , scalarProperty , this ) ) ; continue ; } } mappingScalarProperties . Add ( new MappingFunctionImportScalarProperty ( _context , property , this ) ) ; } } } return mappingScalarProperties ; }
Returns list of MappingFunctionImportScalarProperty for each Property from the ReturnType of the FunctionImport
Returns list of MappingFunctionImportScalarProperty for each Property from the ReturnType of the FunctionImport
// first get the ReturnType of the FunctionImport (should be either EntityType or ComplexType) // check wether we have corresponding TypeMapping inside the FunctionImportMapping // check whether we already have ScalarProperty for this Property // add existing ScalarProperty to the list // if not, add a dummy node