views:

98

answers:

0

Hello, everyone

I'm currently working a relationship Tree for a given GUID. i'm working on Dynamic CRM 4, C# and a SQL 2005 database. i have done the mapping, but one of the requirments is that near the name of each related entity, i will also add the description of the relation as defined in the CRM. since the description name cannot be found in the Metadata, and needs to be retrieved from the database, i have succesfully built the following query to get the description name which are from type OneToMany.

 string SQL = @" select Label from MetadataSchema.LocalizedLabel
                    where  ObjectColumnName  = 'Description'
                    and objectid in 
                    (
                        select ReferencingAttributeId from MetadataSchema.Relationship
                        where name = '" + _meta.SchemaName + @"'
                    )";
        //_meta.SchemaName gives the logical name of the relation

initally i thought that since all the relationships are represented in the same table in the database, "MetadataSchema.Relationships" and the difference between the relationships is represented by only a numeric field which states the kind of the relationship. that the same query would work for returning descriptions for ManyToMany relationships. however, that isn't the case and the result of the query always returns a rows count of zero.

so my question is, why the same query dosen't work for ManyToMany relations and what adjusments to i need to do to my query, in order to get the descriptions.

thanks. Eran