private static Guid DeleteDataMap(CrmOrganizationServiceContext serviceContext, string dataMapName)
        {
            Entity entity = serviceContext.CreateQuery("importmap").FirstOrDefault(s => s.GetAttributeValue <string>("name") == dataMapName);

            if (entity == null)
            {
                return(Guid.Empty);
            }

            Guid dataMapId = entity.Id;

            serviceContext.Delete("importmap", dataMapId);
            return(dataMapId);
        }
Exemple #2
0
        public static void DeleteEntity(Entity entity, CrmConnection connection = null)
        {
            connection.Timeout = new TimeSpan(0, 10, 0);
            using (CrmOrganizationServiceContext service = new CrmOrganizationServiceContext(connection ?? XrmConnection.Connection))
            {
                try
                {
                    service.Delete(entity.LogicalName, entity.Id);
                }
                catch (FaultException <OrganizationServiceFault> fault)
                {
                    throw fault;
                }

                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private static Guid DeleteDataMap(CrmOrganizationServiceContext serviceContext, string dataMapName)
        {
            Entity entity = serviceContext.CreateQuery("importmap").FirstOrDefault(s => s.GetAttributeValue<string>("name") == dataMapName);
            if (entity == null)
            {
                return Guid.Empty;
            }

            Guid dataMapId = entity.Id;
            serviceContext.Delete("importmap", dataMapId);
            return dataMapId;
        }