示例#1
0
 private async Task <JsonArrayResponse <TData> > GetJsonArrayResponse <TData>(
     string requestUrl,
     Func <JToken, object, TData> convert,
     bool withAnnotations = false,
     JsonArrayResponse <TData> previousResponse = null,
     object eventArgs = null,
     Policy <HttpResponseMessage> retryPolicy = null)
 {
     return(new JsonArrayResponse <TData>(
                response: await this.GetJsonResponse(
                    requestUrl: previousResponse == null ? requestUrl : (string.IsNullOrEmpty(previousResponse.NextLink) ? requestUrl : previousResponse.NextLink),
                    withAnnotations: withAnnotations,
                    usingFullLink: previousResponse != null && !string.IsNullOrEmpty(previousResponse.NextLink),
                    retryPolicy: retryPolicy),
                convert: convert,
                eventArgs: eventArgs,
                page: previousResponse == null ? 1 : previousResponse.Page + 1));
 }
示例#2
0
 public Task <JsonArrayResponse <TData, TEventArgs> > List <TData, TEventArgs>(
     string entitySetName,
     string subEntitySetName = null,
     Guid?itemId             = null,
     string fetchXml         = null,
     string select           = null,
     string inlineCount      = null,
     string filter           = null,
     int?top              = null,
     string orderby       = null,
     string expand        = null,
     string expandSelect  = null,
     string expandFilter  = null,
     bool withAnnotations = false,
     Func <JToken, TEventArgs, TData> convert = null,
     TEventArgs eventArgs = default(TEventArgs),
     JsonArrayResponse <TData, TEventArgs> previousResponse = null,
     Policy <HttpResponseMessage> retryPolicy = null)
 {
     return(this.GetJsonArrayResponse(
                requestUrl: BuildRequestUrl(
                    entitySetName: entitySetName,
                    subEntitySetName: subEntitySetName,
                    itemId: itemId,
                    fetchXml: fetchXml,
                    select: select,
                    inlineCount: inlineCount,
                    filter: filter,
                    orderby: orderby,
                    expand: expand,
                    expandSelect: expandSelect,
                    expandFilter: expandFilter,
                    top: top),
                convert: convert,
                withAnnotations: withAnnotations,
                previousResponse: previousResponse,
                eventArgs: eventArgs,
                retryPolicy: retryPolicy));
 }
示例#3
0
        public static async Task <IEnumerable <IEntityMetadata> > GetAllEntityMetadataAsync(this CrmClient crmClient, bool expandAttributes = true)
        {
            JsonArrayResponse      metadataRecordsResponse = null;
            List <IEntityMetadata> metadataRecords         = null;

            do
            {
                metadataRecordsResponse = await crmClient.List(
                    entitySetName : "EntityDefinitions",
                    select : "MetadataId, LogicalName, DisplayName, EntitySetName, PrimaryIdAttribute, PrimaryNameAttribute",
                    previousResponse : metadataRecordsResponse);

                foreach (var metadataJson in metadataRecordsResponse)
                {
                    metadataRecords.Add(new EntityMetadata(metadataJson));
                }

                metadataRecordsResponse.Clear();
            }while (!string.IsNullOrEmpty(metadataRecordsResponse.NextLink));
            metadataRecordsResponse.Destroy();
            return(metadataRecords);
        }