private void UpdateTermSet(ClientContext sourceClientContext, ClientContext targetClientContext, TermSet sourceTermset, TermSet targetTermSet) { targetTermSet.Description = sourceTermset.Description; targetTermSet.IsAvailableForTagging = sourceTermset.IsAvailableForTagging; targetTermSet.Contact = sourceTermset.Contact; // We're not allowing term creation as the target termset should stay in sync with the source targetTermSet.IsOpenForTermCreation = false; // Copy termset properties if (sourceTermset.CustomProperties.Count > 0) { // add properties from source foreach (KeyValuePair<string, string> property in sourceTermset.CustomProperties) { targetTermSet.SetCustomProperty(property.Key, property.Value); } } if (targetTermSet.CustomProperties.Count > 0) { //remove properties which are not needed anymore foreach (KeyValuePair<string, string> property in targetTermSet.CustomProperties) { if (!sourceTermset.CustomProperties.Keys.Contains(property.Key, StringComparer.InvariantCultureIgnoreCase)) { targetTermSet.DeleteCustomProperty(property.Key); } } } targetClientContext.ExecuteQuery(); }