Exemplo n.º 1
0
        private void _init()
        {
            var token = new CrmAuthenticationToken();

            token.AuthenticationType = 0;
            //token.OrganizationName = "pccrm";
            token.OrganizationName = "testenvironment";

            Console.WriteLine("Connecting to CRM: " + token.OrganizationName);

            var service = new SdkTypeProxy.CrmService();

            service.Url = "http://pci-app/mscrmservices/2007/crmservice.asmx";
            service.CrmAuthenticationTokenValue = token;
            service.Credentials = System.Net.CredentialCache.DefaultCredentials;

            _service = service;
        }
        public List <DynamicEntity> RetrieveMultiple(FilterExpression filterExpression, OrderExpression orderExpression, String[] columnSet)
        {
            QueryExpression query = new QueryExpression()
            {
                EntityName = base.EntityName,
                Criteria   = filterExpression,
                ColumnSet  = new ColumnSet(columnSet)
            };

            if (orderExpression != null)
            {
                query.Orders.Add(orderExpression);
            }

            var request = new SdkTypeProxy.RetrieveMultipleRequest()
            {
                ReturnDynamicEntities = true,
                Query = query
            };

            SdkTypeProxy.CrmService service = ServiceBroker.GetServiceInstance(_authRequest);
            SdkTypeProxy.RetrieveMultipleResponse retrieveMultipleResponse = (SdkTypeProxy.RetrieveMultipleResponse)service.Execute(request);
            return(retrieveMultipleResponse.BusinessEntityCollection.BusinessEntities.Select(e => (DynamicEntity)e).ToList());
        }