delete records RRS feed

  • Question

  • I'm trying to delete records from the system using the following code but keep getting a WebException "The operation has timed out" on the Delete call.  Any ideas on what i can do to get these to delete?

    //create query expression to get all accounts
          xrm.QueryExpression accountQuery = new xrm.QueryExpression();
          accountQuery.EntityName = xrm.EntityName.lead.ToString();
          accountQuery.ColumnSet = new xrm.AllColumns();
          xrm.BusinessEntity[] leads = crmservice.RetrieveMultiple(accountQuery).BusinessEntities;
          foreach (xrm.lead l in leads)
            crmservice.Delete(xrm.EntityName.lead.ToString(), l.leadid.Value);
    Tuesday, June 29, 2010 6:30 PM