Hi,
:) dachte ich mir das der Satz gefällt habe das momentan so gelöst
// Set up the CRM Service.
CrmService service = new CrmService();
service.Credentials = System.Net.
CredentialCache.DefaultCredentials;
// Create the ColumnSet that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();
// Set the properties of the ColumnSet.
cols.Attributes =
new string[] { "contactid" };
// Create the ConditionExpression.
ConditionExpression condition = new ConditionExpression();
// Set the condition for the retrieval to be when the city in the contact's address is Sammamish.
condition.AttributeName =
"contactid";
condition.Operator =
ConditionOperator.NotNull;
// Create the FilterExpression.
FilterExpression filter = new FilterExpression();
// Set the properties of the filter.
filter.FilterOperator =
LogicalOperator.And;
filter.Conditions =
new ConditionExpression[] { condition };
// Create the QueryExpression object.
QueryExpression query = new QueryExpression();
// Set the properties of the QueryExpression object.
query.EntityName =
EntityName.contact.ToString();
query.ColumnSet = cols;
query.Criteria = filter;
// Retrieve the contacts.
BusinessEntityCollection contacts = service.RetrieveMultiple(query);
for (int i = 0; i < contacts.BusinessEntities.Length; i++)
{
contact a = (contact)contacts.BusinessEntities[i];
// contactGuid is the GUID of the record being deleted.
Guid contactGuid = new Guid(a.contactid.Value.ToString());
// Delete the contact.
// The EntityName indicates the EntityType of the object being deleted.
service.Delete(
EntityName.contact.ToString(), contactGuid);
zaehler = zaehler +1;
}
ist ja auch alles ganz schön und gut soweit, nur leider dauert das super lange. Da lese ic schneller Kontakte ein als das ich Sie löschen kann. Naja trotzdem danke muss ich wohl durch.
mfg