/// <summary>
        /// Apply the $skiptoken query to the given IQueryable.
        /// </summary>
        /// <param name="query">The original <see cref="IQueryable"/>.</param>
        /// <param name="skipTokenQueryOption">The skiptoken query option which needs to be applied to this query option.</param>
        /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
        public override IQueryable ApplyTo(IQueryable query, SkipTokenQueryOption skipTokenQueryOption)
        {
            if (skipTokenQueryOption == null)
            {
                throw Error.ArgumentNullOrEmpty("skipTokenQueryOption");
            }

            ODataQuerySettings  querySettings = skipTokenQueryOption.QuerySettings;
            ODataQueryOptions   queryOptions  = skipTokenQueryOption.QueryOptions;
            IList <OrderByNode> orderByNodes  = null;

            if (queryOptions != null)
            {
                OrderByQueryOption orderBy = queryOptions.GenerateStableOrder();
                if (orderBy != null)
                {
                    orderByNodes = orderBy.OrderByNodes;
                }
            }

            return(ApplyToCore(query, querySettings, orderByNodes, skipTokenQueryOption.Context, skipTokenQueryOption.RawValue));
        }
        private static IQueryable ApplyToImplementation(IQueryable query, SkipTokenQueryOption skipTokenQueryOption,
                                                        ODataQuerySettings querySettings, ODataQueryOptions queryOptions)
        {
            if (query == null)
            {
                throw Error.ArgumentNull(nameof(query));
            }

            if (skipTokenQueryOption == null)
            {
                throw Error.ArgumentNull(nameof(skipTokenQueryOption));
            }

            if (querySettings == null)
            {
                throw Error.ArgumentNull(nameof(querySettings));
            }

            ODataQueryContext context = skipTokenQueryOption.Context;

            if (context.ElementClrType == null)
            {
                throw Error.NotSupported(SRResources.ApplyToOnUntypedQueryOption, "ApplyTo");
            }

            IList <OrderByNode> orderByNodes = null;

            if (queryOptions != null)
            {
                OrderByQueryOption orderBy = queryOptions.GenerateStableOrder();
                if (orderBy != null)
                {
                    orderByNodes = orderBy.OrderByNodes;
                }
            }

            return(ApplyToCore(query, querySettings, orderByNodes, skipTokenQueryOption.Context, skipTokenQueryOption.RawValue));
        }
        private void BuildQueryOptions(IDictionary <string, string> queryParameters)
        {
            foreach (KeyValuePair <string, string> kvp in queryParameters)
            {
                switch (kvp.Key.ToLowerInvariant())
                {
                case "$filter":
                    ThrowIfEmpty(kvp.Value, "$filter");
                    RawValues.Filter = kvp.Value;
                    Filter           = new FilterQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$orderby":
                    ThrowIfEmpty(kvp.Value, "$orderby");
                    RawValues.OrderBy = kvp.Value;
                    OrderBy           = new OrderByQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$top":
                    ThrowIfEmpty(kvp.Value, "$top");
                    RawValues.Top = kvp.Value;
                    Top           = new TopQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$skip":
                    ThrowIfEmpty(kvp.Value, "$skip");
                    RawValues.Skip = kvp.Value;
                    Skip           = new SkipQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$select":
                    RawValues.Select = kvp.Value;
                    break;

                case "$count":
                    ThrowIfEmpty(kvp.Value, "$count");
                    RawValues.Count = kvp.Value;
                    Count           = new CountQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$expand":
                    RawValues.Expand = kvp.Value;
                    break;

                case "$format":
                    RawValues.Format = kvp.Value;
                    break;

                case "$skiptoken":
                    RawValues.SkipToken = kvp.Value;
                    SkipToken           = new SkipTokenQueryOption(kvp.Value, Context);
                    break;

                case "$deltatoken":
                    RawValues.DeltaToken = kvp.Value;
                    break;

                case "$apply":
                    ThrowIfEmpty(kvp.Value, "$apply");
                    RawValues.Apply = kvp.Value;
                    Apply           = new ApplyQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$compute":
                    ThrowIfEmpty(kvp.Value, "$compute");
                    RawValues.Compute = kvp.Value;
                    Compute           = new ComputeQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                case "$search":
                    ThrowIfEmpty(kvp.Value, "$search");
                    RawValues.Search = kvp.Value;
                    Search           = new SearchQueryOption(kvp.Value, Context, _queryOptionParser);
                    break;

                default:
                    // we don't throw if we can't recognize the query
                    break;
                }
            }

            if (RawValues.Select != null || RawValues.Expand != null)
            {
                SelectExpand = new SelectExpandQueryOption(RawValues.Select, RawValues.Expand,
                                                           Context, _queryOptionParser);
            }

            if (Request.IsCountRequest())
            {
                Count = new CountQueryOption(
                    "true",
                    Context,
                    new ODataQueryOptionParser(
                        Context.Model,
                        Context.ElementType,
                        Context.NavigationSource,
                        new Dictionary <string, string> {
                    { "$count", "true" }
                },
                        Context.RequestContainer));
            }
        }
 /// <summary>
 /// Apply the $skiptoken query to the given IQueryable.
 /// </summary>
 /// <param name="query">The original <see cref="IQueryable"/>.</param>
 /// <param name="skipTokenQueryOption">The skiptoken query option which needs to be applied to this query option.</param>
 /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
 public override IQueryable <T> ApplyTo <T>(IQueryable <T> query, SkipTokenQueryOption skipTokenQueryOption)
 {
     return(ApplyTo(query, skipTokenQueryOption));
 }
 /// <summary>
 /// Apply the $skiptoken query to the given IQueryable.
 /// </summary>
 /// <param name="query">The original <see cref="IQueryable"/>, not null.</param>
 /// <param name="skipTokenQueryOption">The skiptoken query option which needs to be applied to this query option, not null.</param>
 /// <param name="querySettings">The query settings to use while applying this query option, not null.</param>
 /// <param name="queryOptions">Information about the other query options, could be null.</param>
 /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
 public override IQueryable ApplyTo(IQueryable query, SkipTokenQueryOption skipTokenQueryOption,
                                    ODataQuerySettings querySettings, ODataQueryOptions queryOptions)
 {
     return(ApplyToImplementation(query, skipTokenQueryOption, querySettings, queryOptions));
 }
Exemple #6
0
 /// <summary>
 /// Apply the $skiptoken query to the given IQueryable.
 /// </summary>
 /// <param name="query">The original <see cref="IQueryable"/>.</param>
 /// <param name="skipTokenQueryOption">The query option that contains all the relevant information for applying skiptoken.</param>
 /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
 public abstract IQueryable ApplyTo(IQueryable query, SkipTokenQueryOption skipTokenQueryOption);
Exemple #7
0
 /// <summary>
 /// Apply the $skiptoken query to the given IQueryable.
 /// </summary>
 /// <param name="query">The original <see cref="IQueryable"/>.</param>
 /// <param name="skipTokenQueryOption">The query option that contains all the relevant information for applying skiptoken.</param>
 /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
 public abstract IQueryable <T> ApplyTo <T>(IQueryable <T> query, SkipTokenQueryOption skipTokenQueryOption);
Exemple #8
0
 /// <summary>
 /// Apply the $skiptoken query to the given IQueryable.
 /// </summary>
 /// <param name="query">The original <see cref="IQueryable"/>.</param>
 /// <param name="skipTokenQueryOption">The query option that contains all the relevant information for applying skiptoken.</param>
 /// <param name="querySettings">The query settings to use while applying this query option.</param>
 /// <param name="queryOptions">Information about the other query options.</param>
 /// <returns>The new <see cref="IQueryable"/> after the skiptoken query has been applied to.</returns>
 public abstract IQueryable ApplyTo(IQueryable query, SkipTokenQueryOption skipTokenQueryOption,
                                    ODataQuerySettings querySettings, ODataQueryOptions queryOptions);