private Property SetGetEntitiesRESTProperties(Property prop, CRMFetchXML task)
 {
     if (task != null)
     {
         switch (prop.Name.ToLower())
         {
             case "fetchxml":
                 prop.Value = task.FetchXML;
                 break;
         }
     }
     
     return prop;
 }
    public CRMFetchXML CRMGetEntities(CRMFetchXML crmFetchXML)
    {
        CRMFunctions function = new CRMFunctions(crmFetchXML.Config);

        return(function.CRMGetEntities(crmFetchXML));
    }
        private void GetEntities(ref ServiceObject so)
        {
            SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0];

            CRMFetchXML fetch = new CRMFetchXML();
            fetch.Config = crmconfig;

            try
            {
                fetch.FetchXML = NotNull(so.Properties["FetchXML"].Value);

                CRMFetchXML response = CRMFunctions.CRMGetEntities(fetch);
               
                so.Properties.InitResultTable();

                if (response.Entities != null)
                {
                    foreach (CRMState state in response.Entities)
                    {
                        for (int c = 0; c < meth.ReturnProperties.Count; c += 1)
                        {
                            Property prop = so.Properties[meth.ReturnProperties[c]];
                            prop = SetGetEntitiesProperties(prop, state);
                            prop = SetGetEntitiesRESTProperties(prop, response);
                        }
                        so.Properties.BindPropertiesToResultTable();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }