locked
Error when using aliased value in FetchXML query in silverlight RRS feed

  • Question

  • Hello Everyone,

    I am trying to make a fetchXML query from my Silverlight app. 

    This is the query I am using:

    <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                                    <entity name='promx_project'>
                                                    <attribute name='promx_projectname' />
                                                    <attribute name='statuscode' />
                                                    <attribute name='promx_projecttypelookup' />
                                                    <attribute name='promx_baseprojectlookup' />
                                                    <attribute name='promx_accountlookup' />
                                                    <attribute name='promx_type' />
                                                    <attribute name='promx_defaultactivityrecordtypeid' />
                                                    <attribute name='promx_timeunitlookup' />
                                                        <link-entity name='promx_project' from='promx_projectid' to='promx_baseprojectlookup' alias='baseproject' link-type='outer'>
                                                            <attribute name='promx_projectname' />
                                                        </link-entity>
                                                    <filter type='or'>      
                                                        <condition attribute='promx_projectname' operator='like' value='%{0}%' />
                                                        <filter type='and'>
                                                          <condition entityname='baseproject' attribute='promx_projectname' operator='not-null' />
                                                          <condition entityname='baseproject' attribute='promx_projectname' operator='like' value='%{0}%' />
                                                        </filter>
                                                    </filter>
                                                    </entity>
                                                </fetch>

    It is working fine with fetchXML tester, but it gives the following error when I debug in silverlight:

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:RetrieveMultipleResult. The InnerException message was 'Error in line 1 position 3743. Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data of the 'http://schemas.microsoft.com/xrm/2011/Contracts:AliasedValue' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'AliasedValue' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

    Other queries work fine, just this one fails, I guess because it is using an alias. I tried to manually add a KnownTypeAttribute to the Reference.cs, but I am not sure where to insert it.

    Any ideas?

    Regards,

    Adam

    Thursday, November 13, 2014 1:19 PM