示例#1
0
        /// <summary>
        /// Applies the query to the given IQueryable based on incoming query from uri and query settings. By default,
        /// the implementation supports $top, $skip, $orderby and $filter. Override this method to perform additional
        /// query composition of the query.
        /// </summary>
        /// <param name="queryable">The original queryable instance from the response message.</param>
        /// <param name="queryOptions">
        /// The <see cref="IODataQueryOptions"/> instance constructed based on the incoming request.
        /// </param>
        public virtual IQueryable ApplyQuery(IQueryable queryable, IODataQueryOptions queryOptions)
        {
            if (queryable == null)
            {
                throw Error.ArgumentNull("queryable");
            }
            if (queryOptions == null)
            {
                throw Error.ArgumentNull("queryOptions");
            }

            return(queryOptions.ApplyTo(queryable, _querySettings));
        }
示例#2
0
        /// <summary>
        /// Applies the query to the given entity based on incoming query from uri and query settings.
        /// </summary>
        /// <param name="entity">The original entity from the response message.</param>
        /// <param name="queryOptions">
        /// The <see cref="IODataQueryOptions"/> instance constructed based on the incoming request.
        /// </param>
        /// <returns>The new entity after the $select and $expand query has been applied to.</returns>
        public virtual object ApplyQuery(object entity, IODataQueryOptions queryOptions)
        {
            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }
            if (queryOptions == null)
            {
                throw Error.ArgumentNull("queryOptions");
            }

            return(queryOptions.ApplyTo(entity, _querySettings));
        }
示例#3
0
        public ITestActionResult Get(IODataQueryOptions <CollectionSerializerCustomer> options)
        {
            IQueryable <CollectionSerializerCustomer> customers = new[]
            {
                new CollectionSerializerCustomer {
                    ID = 1, Name = "Name 1"
                },
                new CollectionSerializerCustomer {
                    ID = 2, Name = "Name 2"
                },
                new CollectionSerializerCustomer {
                    ID = 3, Name = "Name 3"
                },
            }.AsQueryable();

            IQueryable <IEdmEntityObject> appliedCustomers = options.ApplyTo(customers) as IQueryable <IEdmEntityObject>;

            return(Ok(appliedCustomers));
        }