Since few months, I work on developing a WPF UI that directly connects to MS Dynamics CRM 4.0. In this post I will present you some of the practices I use in this project.
Specify all desired attributes and not all-attributes element. all-attributes will return all fields of the desired entities:
<attribute name=”…” /> <attribute name=”…” />
<attribute name=”…” />
instead of:
<all-attributes />
I really recommend you to manually set all the attributes you need. This will reduce the size of the response and in a same time, this reduce the SQL request generated by CRM.
Take few minutes to create your own paging mechanism.
Step 1 :
FetchXML offers the ability to return fields from parent entity, linq queries not.
Using aliases for you linked entities will facilitate the execution and your deserialization. If you do not set an alias, you will not be able to return fields with same names from different entities.
Here is the result of previous FetchXML queyry:
In the example, you can now returns createdby (createdon, modifiedby, modifiedon) on two different entities. After in your project, you can easily create you own deserialization mechanism having the alias as parameter.
You cannot use left join using Linq. Fetch queries enable left join. This helps you a lot, if you need to return in each contact query specific fields of parent entity, this reduces the number of request to server.
Here is in 5 points a quick way to generate your FetchXML query:
This will open a pop-up with the expected FetchXml