Associate multiple records

As a variant to a recent post I did, here’s another method to associate records, difference is that this will associate multiple number of records in a single transaction

///
/// Associate multiple records in a single transaction
///
public void AssociateMultipleRecords(EntityReference MainRecord, string RelationshipName, EntityReferenceCollection RecordsToBeAssociated, IOrganizationService Service)
{
    Service.Associate(MainRecord.LogicalName,
                      MainRecord.Id,
                      new Relationship(RelationshipName),
                      RecordsToBeAssociated);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s