1
Vote

Multiple Associations with the Same Type Not Working

description

I'm no edmx expert, but if i have an entity with these navigation properties on my Affiliate entity:
<NavigationProperty Name="HomeAddresses" Relationship="Affiliate_HomeAddress" FromRole="Affiliates" ToRole="Address"/>
<NavigationProperty Name="WorkAddresses" Relationship="Affiliate_WorkAddress" FromRole="Affiliates" ToRole="Address"/>
then i run into all types of problems with the generated code. The Affiliate entity in code will have two Address properties because the transform is defined as:
    //Navigation Property <xsl:value-of select="$Namespace"/>.<xsl:value-of select="@ToRole"/>
    public $<xsl:value-of select="@ToRole"/>;
    </xsl:for-each>
sure seems like the value's shoudl be @Name, not @ToRole. There's a similar problem in the getRelatedResourceReference method of the generated QueryProvider, it'll build an interesting If tree:
if($navigationPropName === 'Address')
                {
                    if (empty($sourceEntityInstance->HomeAddress_AddressID))
                    {
                        $result = null;
                    } else {
                        $query = "SELECT * FROM Addresses WHERE HomeAddress_AddressID = '$sourceEntityInstance->HomeAddress_AddressID'";
                        $stmt = mysql_query($query);
                        if ($stmt === false) {
                            die(print_r(mysql_error(), true));
                        }
                        if (!mysql_num_rows($stmt)) {
                            $result =  null;
                        }
                        $result = $this->_serializeAddress(mysql_fetch_array($stmt, MYSQL_ASSOC));
                    }
                }
                                
                else if($navigationPropName === 'Address')
                {
                    if (empty($sourceEntityInstance->WorkAddress_AddressID))
                    {
                        $result = null;
                    } else {
                        $query = "SELECT * FROM Addresses WHERE WorkAddress_AddressID = '$sourceEntityInstance->WorkAddress_AddressID'";
                        $stmt = mysql_query($query);
                        if ($stmt === false) {
                            die(print_r(mysql_error(), true));
                        }
                        if (!mysql_num_rows($stmt)) {
                            $result =  null;
                        }
                        $result = $this->_serializeAddress(mysql_fetch_array($stmt, MYSQL_ASSOC));
                    }
                }

comments