Exemple #1
0
        /// <inheritdoc/>
        public virtual Task <Entity> RetrieveAsync(string entityName, Guid id, [AllowNull] QueryOptions options = null,
                                                   CancellationToken cancellationToken = default)
        {
            var requestId = Guid.NewGuid();

            var queryString = (options ?? new QueryOptions()).BuildQueryString(WebApiMetadata, entityName);

            var entityMd = WebApiMetadata.GetEntityMetadata(entityName);

            var request = $"{entityMd.EntitySetName}({id}){queryString}";

            return(GetAsync <Entity>(request, requestId, cancellationToken));
        }
Exemple #2
0
        public virtual Task <EntityCollection> RetrieveMultipleAsync(FetchXmlExpression fetchXml,
                                                                     CancellationToken cancellationToken = default)
        {
            if (fetchXml is null)
            {
                throw new ArgumentNullException(nameof(fetchXml));
            }

            var entityMetadata = WebApiMetadata.GetEntityMetadata(fetchXml.EntityName);

            var query = $"{entityMetadata.EntitySetName}?fetchXml={System.Net.WebUtility.UrlEncode(fetchXml)}";

            return(ExecuteFunctionAsync <EntityCollection>(query, cancellationToken));
        }
Exemple #3
0
        public virtual Task <EntityCollection> RetrieveMultipleAsync(string entityName,
                                                                     [AllowNull] QueryOptions options    = null,
                                                                     CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"Start RetrieveMultipleAsync at {entityName}");

            var queryString = (options ?? new QueryOptions())
                              .BuildQueryString(WebApiMetadata, entityName);

            var entityMd = WebApiMetadata.GetEntityMetadata(entityName);

            var request = $"{entityMd.EntitySetName}{queryString}";

            return(ExecuteFunctionAsync <EntityCollection>(request, cancellationToken));
        }
Exemple #4
0
        /// <inheritdoc/>
        public virtual Task <EntityCollection> RetrieveMultipleAsync(string entityName,
                                                                     [AllowNull] QueryOptions options    = null,
                                                                     CancellationToken cancellationToken = default)
        {
            _logger.LogDebug("Starting {WebApiOperationName} at {TargetEntity}",
                             "RetrieveMultiple", entityName);

            var requestId = Guid.NewGuid();

            var queryString = (options ?? new QueryOptions())
                              .BuildQueryString(WebApiMetadata, entityName);

            var entityMd = WebApiMetadata.GetEntityMetadata(entityName);

            var request = $"{entityMd.EntitySetName}{queryString}";

            return(GetAsync <EntityCollection>(request, requestId, cancellationToken));
        }
Exemple #5
0
        public virtual Task <Entity> RetrieveAsync(string entityName, Guid id, [AllowNull] QueryOptions options = null,
                                                   CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"Start RetrieveAsync at {entityName} with id = {id}");

            var queryString = (options ?? new QueryOptions())
                              .BuildQueryString(WebApiMetadata, entityName);

            var entityMd = WebApiMetadata.GetEntityMetadata(entityName);

            var request = $"{entityMd.EntitySetName}({id}){queryString}";


            var entity = ExecuteFunctionAsync <Entity>(request, cancellationToken);

            _logger.LogInformation($"Finish RetrieveAsync at {entityName} with id = {id}");

            return(entity);
        }