Class ODataQueryOptions
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
ODataQueryContextThe ODataQueryContext which contains the Microsoft.Data.Edm.IEdmModel and some type information.
request
HttpRequestMessageThe incoming request message.
Properties
Context
Gets the given ODataQueryContext
public ODataQueryContext Context { get; }
Property Value
Filter
Gets the FilterQueryOption.
public FilterQueryOption Filter { get; }
Property Value
InlineCount
Gets the InlineCountQueryOption.
public InlineCountQueryOption InlineCount { get; }
Property Value
OrderBy
Gets the OrderByQueryOption.
public OrderByQueryOption OrderBy { get; }
Property Value
RawValues
Gets the raw string of all the OData query options
public ODataRawQueryOptions RawValues { get; }
Property Value
Request
Gets the request message associated with this instance.
public HttpRequestMessage Request { get; }
Property Value
SelectExpand
Gets the SelectExpandQueryOption.
public SelectExpandQueryOption SelectExpand { get; }
Property Value
Skip
Gets the SkipQueryOption.
public SkipQueryOption Skip { get; }
Property Value
Top
Gets the TopQueryOption.
public TopQueryOption Top { get; }
Property Value
Validator
Gets or sets the query validator.
public ODataQueryValidator Validator { get; set; }
Property Value
Methods
ApplyTo(IQueryable)
Apply the individual query to the given IQueryable in the right order.
public virtual IQueryable ApplyTo(IQueryable query)
Parameters
query
IQueryableThe 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
IQueryableThe original IQueryable.
querySettings
ODataQuerySettingsThe 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
objectThe original entity.
querySettings
ODataQuerySettingsThe 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
stringThe 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
intThe query result limit.
resultsLimited
booltrue 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
ODataValidationSettingsThe ODataValidationSettings instance which contains all the validation settings.