Пример #1
0
        public OrganizationResponse Execute(OrganizationRequest request)
        {
            if (request.GetType().Name == "RetrieveMultipleRequest")
            {
                RetrieveMultipleResponse response = new RetrieveMultipleResponse();
                EntityCollection         result   = RetrieveMultiple((( RetrieveMultipleRequest )request).Query);
                response.Results["EntityCollection"] = result;
                return(response);
            }
            else if (request.GetType().Name == "RetrieveRequest")
            {
                RetrieveResponse response        = new RetrieveResponse();
                RetrieveRequest  retrieveRequest = ( RetrieveRequest )request;
                EntityReference  target          = retrieveRequest.Target;


                if (target.GetType().Name == "TargetRetrieveDynamic")
                {
                    /*
                     * TargetRetrieveDynamic trd = ( TargetRetrieveDynamic )target;
                     *      response.Entity = Retrieve( trd.EntityName, trd.EntityId, retrieveRequest.ColumnSet );
                     */
                }


                // TODO: entity is readonly .. will have to set this with reflection
                // response.Entity = Retrieve( target.LogicalName, target.Id, retrieveRequest.ColumnSet );

                else
                {
                    // request sent using a specific strongly-typed business entity
                    // rather than a DynamicEntity
                    throw new NotImplementedException();
                }
                return(response);
            }
            else if (request.GetType().Name == "CreateRequest")
            {
                CreateResponse response = new CreateResponse();
                Guid           result   = Create((( CreateRequest )request).Target);
                response.Results["id"] = result;
                return(response);
            }
            else if (request.GetType().Name == "UpdateRequest")
            {
                UpdateResponse response = new UpdateResponse();
                Update((( UpdateRequest )request).Target);
                return(response);
            }
            else
            {
                throw new NotImplementedException();
            }
        }