private void mergeSample()
        {
            // TODO Auto-generated method stub
            // Verify that we are already authenticated, if not
            // call the login function to do so
            if (!loggedIn)
            {
                if (!login())
                {
                    return;
                }
            }

            try
            {
                sObject masterAccount = new sObject();
                masterAccount.type = "Account";
                masterAccount.Any = new System.Xml.XmlElement[] { GetNewXmlElement("Name", "MasterAccount") };
                SaveResult masterAccountSaveResult;
                masterAccountSaveResult = binding.create(new sObject[] { masterAccount })[0];
                masterAccount.Id = masterAccountSaveResult.id;
                System.Xml.XmlElement[] masterAny = masterAccount.Any;
                System.Array.Resize(ref masterAny, (masterAccount.Any.Length + 1));
                masterAny[masterAny.Length - 1] = GetNewXmlElement("Description", "Old description");
                masterAccount.Any = masterAny;

                sObject accountToMerge = new sObject();
                accountToMerge.type = "Account";
                accountToMerge.Any = new System.Xml.XmlElement[] { GetNewXmlElement("Name", "AccountToMerge"),
                    GetNewXmlElement("Description", "Duplicate account") };

                SaveResult accountToMergeSaveResult = binding.create(new sObject[] { accountToMerge })[0];

                //Attach a note, which will get re-parented
                sObject note = new sObject();
                note.type = "Note";
                note.Any = new System.Xml.XmlElement[] { GetNewXmlElement("ParentId", accountToMergeSaveResult.id),
                    GetNewXmlElement("Body", "This note will be moved to the MasterAccount during merge"),
                    GetNewXmlElement("Title", "Test note to be reparented.") };

                SaveResult noteSave = binding.create(new sObject[] { note })[0];

                MergeRequest mr = new MergeRequest();

                //Perform an update on the master record as part of the merge:
                masterAccount.Any[masterAccount.Any.Length - 1] = GetNewXmlElement("Description", "Was merged");

                mr.masterRecord = masterAccount;
                mr.recordToMergeIds = (new String[] { accountToMergeSaveResult.id });
                MergeResult result = binding.merge(new MergeRequest[] { mr })[0];

                Console.WriteLine("Merged " + result.success + " got " +
                result.updatedRelatedIds.Length + " updated child records\nHit return to continue.");
                Console.ReadLine();

            }
            catch (System.Web.Services.Protocols.SoapException e)
            {
                Console.WriteLine("Error merging account: " + e.Message + "\nHit return to continue...");
                Console.ReadLine();
            }
        }
 /// <remarks/>
 public void mergeAsync(MergeRequest[] request) {
     this.mergeAsync(request, null);
 }
 /// <remarks/>
 public void mergeAsync(MergeRequest[] request, object userState) {
     if ((this.mergeOperationCompleted == null)) {
         this.mergeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnmergeOperationCompleted);
     }
     this.InvokeAsync("merge", new object[] {
                 request}, this.mergeOperationCompleted, userState);
 }
 /// <remarks/>
 public System.IAsyncResult Beginmerge(MergeRequest[] request, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("merge", new object[] {
                 request}, callback, asyncState);
 }