A little while back I blogged about how when using the default behavior of OData from Silverlight all properties are sent with each server update by default. I also included in that blog post a link to the CRM Team blog post with a work around you can find that here.
The workaround is designed to track properties that are changed on an entity and only ship those to the server during a create or update. Turns out, the work around doesn’t appear to send N:1 relationships to the server depending on how you set or modify the value of the property.
Imagine you have an entity Book and the Book Entity had a N:1 relationship to Contact and a attribute crmbook_contactid was created on the entity. If you set the value of this like the following:
bookInstance.crmbook_contactid = new EntityReference {id=idValue,Contact.LogicalName};
You will find this won’t send the value to the server. If you are curious, the id and logicalname properties are marked as changed in the tracking of what is dirty, but not the crmbook_contactid property. What I have found to work is the following:
First, Create the entity Reference
var myRef = new EntityReference {id=idValue,Contact.LogicalName};
Then set the value
bookInstance.crmbook_contactid = myRef;
Setting it this way I found properly triggered the change notification for crmbook_contactid causing it to be marked as dirty and sent as part of the create or update.