Table of Contents

Class EntityQuery

Namespace
Breeze.Core
Assembly
Breeze.Core.dll

A query as it arrived from a Breeze client: a resource name, a where clause, and the orderBy, select, expand, skip and take that go with it.

public class EntityQuery
Inheritance
EntityQuery
Inherited Members
Extension Methods

Remarks

A query is parsed from JSON by the EntityQuery(string?) constructor, checked against the entity type by Validate(Type), and then applied to an IQueryable by the extension methods in EntityQueryExtensions.

Every clause method returns a new query rather than changing this one, so a query can be safely shared and built on.

Constructors

EntityQuery()

Create an empty query, to be built up with the clause methods.

public EntityQuery()

EntityQuery(EntityQuery)

Copy a query. Used by the clause methods, which each return a new query.

public EntityQuery(EntityQuery query)

Parameters

query EntityQuery

The query to copy.

EntityQuery(string?)

Parse a query from the JSON a Breeze client sent.

public EntityQuery(string? json)

Parameters

json string

The serialized query. Null or empty yields an empty query.

Exceptions

Exception

The string is not valid JSON, or is not a JSON object.

Properties

AfterExecution

After the query was executed, post-process the resulting list and return the list

public static Func<EntityQuery, IQueryable, IList, IList> AfterExecution { get; set; }

Property Value

Func<EntityQuery, IQueryable, IList, IList>

ApplyCustomLogic

Apply logic to the IQueryable after the Where clause is applied, but before Order/Skip/Take/Select

public static Func<EntityQuery, IQueryable, Type, IQueryable> ApplyCustomLogic { get; set; }

Property Value

Func<EntityQuery, IQueryable, Type, IQueryable>

ApplyExpand

Apply expand clauses to the IQueryable after Order/Skip/Take/Select, but before execution

public static Func<EntityQuery, IQueryable, Type, IQueryable> ApplyExpand { get; set; }

Property Value

Func<EntityQuery, IQueryable, Type, IQueryable>

EntityType

The type this query was validated against. Null until Validate(Type) has run.

public Type? EntityType { get; }

Property Value

Type

ExpandClause

The expand clause, or null if the query expands nothing.

public ExpandClause? ExpandClause { get; }

Property Value

ExpandClause

IsInlineCountEnabled

Whether the query asked for the total row count alongside the results.

public bool IsInlineCountEnabled { get; }

Property Value

bool

NeedsExecution

Whether query string needs execution

public static Func<string?, IQueryable?, bool> NeedsExecution { get; set; }

Property Value

Func<string, IQueryable, bool>

Remarks

Either argument may be null: the query string when the request has none, the IQueryable when the action result is not a queryable.

OrderByClause

The orderBy clause, or null if the query does not sort.

public OrderByClause? OrderByClause { get; }

Property Value

OrderByClause

ResourceName

The url resource being queried, or null if the query did not name one.

public string? ResourceName { get; }

Property Value

string

SelectClause

The select clause, or null if the query returns whole entities.

public SelectClause? SelectClause { get; }

Property Value

SelectClause

SkipCount

The number of rows to skip, or null if the query does not skip.

public int? SkipCount { get; }

Property Value

int?

TakeCount

The number of rows to take, or null if the query is unlimited.

public int? TakeCount { get; }

Property Value

int?

WherePredicate

The where clause, or null if the query has none.

public BasePredicate? WherePredicate { get; }

Property Value

BasePredicate

Methods

EnableInlineCount(bool)

Return a new query that does, or does not, ask for the total row count alongside the results.

public EntityQuery EnableInlineCount(bool inlineCountEnabled)

Parameters

inlineCountEnabled bool

True to return the count as well as the rows.

Returns

EntityQuery

A new query; this one is unchanged.

Expand(List<string>)

Return a new query with the given expand clauses appended.

public EntityQuery Expand(List<string> propertyPaths)

Parameters

propertyPaths List<string>

Navigation paths to load, each dot-delimited.

Returns

EntityQuery

A new query; this one is unchanged.

Expand(params string[])

Return a new query with the given expand clauses appended.

public EntityQuery Expand(params string[] propertyPaths)

Parameters

propertyPaths string[]

Navigation paths to load, each dot-delimited.

Returns

EntityQuery

A new query; this one is unchanged.

GetParameters()

The parameters the client sent, for a named query method that takes some.

public IDictionary<string, object?>? GetParameters()

Returns

IDictionary<string, object>

The parameters by name, or null if the query carried none.

OrderBy(List<string>)

Return a new query with the given orderBy clauses appended.

public EntityQuery OrderBy(List<string> propertyPaths)

Parameters

propertyPaths List<string>

Property paths, each optionally followed by "desc".

Returns

EntityQuery

A new query; this one is unchanged.

OrderBy(params string[])

Return a new query with the given orderBy clauses appended.

public EntityQuery OrderBy(params string[] propertyPaths)

Parameters

propertyPaths string[]

Property paths, each optionally followed by "desc".

Returns

EntityQuery

A new query; this one is unchanged.

Select(IEnumerable<string>)

Return a new query with the given select (projection) clauses appended.

public EntityQuery Select(IEnumerable<string> propertyPaths)

Parameters

propertyPaths IEnumerable<string>

Property paths to project, each dot-delimited.

Returns

EntityQuery

A new query; this one is unchanged.

Select(params string[])

Return a new query with the given select (projection) clauses appended.

public EntityQuery Select(params string[] propertyPaths)

Parameters

propertyPaths string[]

Property paths to project, each dot-delimited.

Returns

EntityQuery

A new query; this one is unchanged.

Skip(int)

Return a new query that skips the first n rows.

public EntityQuery Skip(int skipCount)

Parameters

skipCount int

The number of rows to skip.

Returns

EntityQuery

A new query; this one is unchanged.

Take(int)

Return a new query limited to the first n rows.

public EntityQuery Take(int takeCount)

Parameters

takeCount int

The number of rows to take.

Returns

EntityQuery

A new query; this one is unchanged.

Validate(Type)

Check every clause of this query against the type being queried, resolving their property paths.

public void Validate(Type entityType)

Parameters

entityType Type

The type the query returns.

Remarks

Must run before the query is applied to an IQueryable. It also records EntityType.

Exceptions

Exception

A clause names a property the type does not have, or compares values that cannot be compared.

Where(BasePredicate)

Return a new query with an additional where clause, combined with the existing one using and.

public EntityQuery Where(BasePredicate predicate)

Parameters

predicate BasePredicate

The where clause to add.

Returns

EntityQuery

A new query; this one is unchanged.

Where(string)

Return a new query with an additional where clause, parsed from JSON.

public EntityQuery Where(string json)

Parameters

json string

The where clause as JSON.

Returns

EntityQuery

A new query; this one is unchanged.

WithResourceName(string)

Return a new query aimed at a different resource.

public EntityQuery WithResourceName(string resourceName)

Parameters

resourceName string

The name of the url resource to query.

Returns

EntityQuery

A new query; this one is unchanged.