Table of Contents

Class ODataQueryOptions

Namespace
System.Web.Http.OData.Query
Assembly
System.Web.Http.OData.dll

This defines a composite OData query options that can be used to perform query composition. Currently this only supports $filter, $orderby, $top, $skip, and $inlinecount.

[ODataQueryParameterBinding]
public class ODataQueryOptions
Inheritance
ODataQueryOptions
Derived
Inherited Members

Constructors

ODataQueryOptions(ODataQueryContext, HttpRequestMessage)

Initializes a new instance of the ODataQueryOptions class based on the incoming request and some metadata information from the ODataQueryContext.

public ODataQueryOptions(ODataQueryContext context, HttpRequestMessage request)

Parameters

context ODataQueryContext

The ODataQueryContext which contains the Microsoft.Data.Edm.IEdmModel and some type information.

request HttpRequestMessage

The incoming request message.

Properties

Context

Gets the given ODataQueryContext

public ODataQueryContext Context { get; }

Property Value

ODataQueryContext

Filter

public FilterQueryOption Filter { get; }

Property Value

FilterQueryOption

InlineCount

public InlineCountQueryOption InlineCount { get; }

Property Value

InlineCountQueryOption

OrderBy

public OrderByQueryOption OrderBy { get; }

Property Value

OrderByQueryOption

RawValues

Gets the raw string of all the OData query options

public ODataRawQueryOptions RawValues { get; }

Property Value

ODataRawQueryOptions

Request

Gets the request message associated with this instance.

public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage

SelectExpand

public SelectExpandQueryOption SelectExpand { get; }

Property Value

SelectExpandQueryOption

Skip

Gets the SkipQueryOption.

public SkipQueryOption Skip { get; }

Property Value

SkipQueryOption

Top

Gets the TopQueryOption.

public TopQueryOption Top { get; }

Property Value

TopQueryOption

Validator

Gets or sets the query validator.

public ODataQueryValidator Validator { get; set; }

Property Value

ODataQueryValidator

Methods

ApplyTo(IQueryable)

Apply the individual query to the given IQueryable in the right order.

public virtual IQueryable ApplyTo(IQueryable query)

Parameters

query IQueryable

The original IQueryable.

Returns

IQueryable

The new IQueryable after the query has been applied to.

ApplyTo(IQueryable, ODataQuerySettings)

Apply the individual query to the given IQueryable in the right order.

public virtual IQueryable ApplyTo(IQueryable query, ODataQuerySettings querySettings)

Parameters

query IQueryable

The original IQueryable.

querySettings ODataQuerySettings

The settings to use in query composition.

Returns

IQueryable

The new IQueryable after the query has been applied to.

ApplyTo(object, ODataQuerySettings)

Applies the query to the given entity using the given ODataQuerySettings.

public virtual object ApplyTo(object entity, ODataQuerySettings querySettings)

Parameters

entity object

The original entity.

querySettings ODataQuerySettings

The ODataQuerySettings that contains all the query application related settings.

Returns

object

The new entity after the $select and $expand query has been applied to.

IsSystemQueryOption(string)

Check if the given query option is an OData system query option.

public static bool IsSystemQueryOption(string queryOptionName)

Parameters

queryOptionName string

The name of the query option.

Returns

bool

Returns true if the query option is an OData system query option.

LimitResults<T>(IQueryable<T>, int, out bool)

Limits the query results to a maximum number of results.

public static IQueryable<T> LimitResults<T>(IQueryable<T> queryable, int limit, out bool resultsLimited)

Parameters

queryable IQueryable<T>

The queryable to limit.

limit int

The query result limit.

resultsLimited bool

true if the query results were limited; false otherwise

Returns

IQueryable<T>

The limited query results.

Type Parameters

T

The entity CLR type

Validate(ODataValidationSettings)

Validate all OData queries, including $skip, $top, $orderby and $filter, based on the given validationSettings. It throws an ODataException if validation failed.

public virtual void Validate(ODataValidationSettings validationSettings)

Parameters

validationSettings ODataValidationSettings

The ODataValidationSettings instance which contains all the validation settings.