title: How to bulk remove members from Marketing List?
body: <p>I have a scenario in CRM Dynamics 2013 where I need to remove thousands of records, basically I have contact,account, lead, I need to basically remove all marketing list from contacts where the owner is 'Pending Deletion' so these contacts don't receive the lists, I was wondering which approach would be best, I though maybe if I create a program that uses the RemoveMemberListRequest, all well but how do I specify a query using the sdk that basically says, remove members from list where the contact on the list has a owner set to 'Pending Deletion'.</p>
  
  <p>I see a bit of a concern with this approach, as I plan to use the RemoveMemberListRequest, it looks for guid of EntityId(contact) and guid of ListID(marketing list), the issue is that there are many lists and many contacts that fall under this criteria.The important criteria is focused on the Contacts with owner being Pending Deletion, this means I dont have a specific way to query those specific marketing lists where the contact is added to, has that Pending Deletion as ownwer field. I hope this makes sense, any help would be appreciated.</p>
  
  <p>Please see what I have so far</p>
  
  <pre><code>public static Entity GetConatctWithPendingDeletion(IOrganizationService service)
      {
          QueryExpression qe = new QueryExpression();
          qe.EntityName = "contact";
          qe.ColumnSet = new ColumnSet("fullname", "ownerid", "parentcustomerid", "new_title");
          qe.Criteria.AddCondition("ownerid", ConditionOperator.Equal, "0F040671-1E83-E111-83B9-D067E5EBE694");// tbhis represents the optionset 'Pending Deletion'
  
          EntityCollection response = service.RetrieveMultiple(qe);
  
          return response.Entities[0];
  
          Console.WriteLine(response.Entities.Count());
          Console.ReadLine();
  
          RemoveMemberListRequest req = new RemoveMemberListRequest();
          req.EntityId = new Guid("xxxxxxx-xxx-xxx-xxx-xxxxxxx");//how do I specifty a list of Contact guids based on above code
          req.ListId = new Guid("xxxxxxx-xxxx-xxxx-xxxxx");// Also here , how do I specify the lists I want,
  
          RemoveMemberListResponse resp = (RemoveMemberListResponse)service.Execute(req);
  
  
      }
  </code></pre>