Suppose you have create a new contact and since there is a relationship between contacts and Accounts by default , so you would like to relate this contact to a specific account or to many accounts.
Here comes the Associate Request !!
we will use a class called “Associate Request” which links records to each user assuming there is a relationship between the entities which records belong to .
IOrganizationSericce service; // instance of the organization serivce
Contact contact; //The contact you have
Account account; //The account you have and which you like to link the contact too.
AssociateRequest contactToAccount = new AssociateRequest
//The contact record
Target = new EntityReference(contact.EntityLogicalName, contact.contactId),
//The list of account you would like the contact to be linked with (in this case we have only one account)
RelatedEntities = new EntityReferenceCollection
Relationship = new Relationship(“name of the relationship already existing”)