bool IsHasAleady(CalcService calcService) { var orginal = calcService.GetOriginalFlight(); var id = calcService.Target.Id; if (orginal == null) { throw new InvalidPluginExecutionException("there is no Flight for Service Event"); } var query = ""; if (!_isOnCreate) { query = @"<fetch mapping='logical' version='1.0'> <entity name='new_incidentservice' > <attribute name='new_incidentserviceid' /> <filter type='and'> <condition attribute='new_incidentserviceid' operator='ne' value='" + id.ToString() + @"' /> </filter> <link-entity name='new_flightoccurrence' from='new_flightoccurrenceid' to='new_flight' > <filter type='and'> <condition attribute='new_flightoccurrenceid' operator='eq' value='" + orginal.Id.ToString() + @"' /> </filter> </link-entity> </entity> </fetch>"; } else { query = @"<fetch mapping='logical' version='1.0'> <entity name='new_incidentservice' > <attribute name='new_incidentserviceid' /> <link-entity name='new_flightoccurrence' from='new_flightoccurrenceid' to='new_flight' > <filter type='and'> <condition attribute='new_flightoccurrenceid' operator='eq' value='" + orginal.Id.ToString() + @"' /> </filter> </link-entity> </entity> </fetch>"; } var compensations = calcService.Service.RetrieveMultiple(new FetchExpression(query)); if (compensations.Entities.Count > 0) { return(true); } return(false); }