예제 #1
0
        /// <summary>
        /// Delete all active entities in the entity specified by the LogicalName and the Filter Expression
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="logicalName">The logical name of the entity that will be deleted.</param>
        /// <param name="fe">The filter expression to use to determine what records to delete.</param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static Task <bool> DeleteIfExistsAsync(this IOrganizationServiceAsync2 service, string logicalName, FilterExpression fe, CancellationToken token = default)
        {
            var qe = new QueryExpression(logicalName)
            {
                Criteria = fe
            };

            return(service.DeleteIfExistsAsync(qe, token));
        }
예제 #2
0
 /// <summary>
 /// Attempts to delete the entity with the given id. If it doesn't exist, false is returned
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="entity">The entity to delete if it exists.</param>
 /// <param name="token"></param>
 public static Task DeleteIfExistsAsync(this IOrganizationServiceAsync2 service, Entity entity, CancellationToken token = default)
 {
     return(service.DeleteIfExistsAsync(entity.LogicalName, entity.Id, token));
 }