Table of Contents

Class QueryFns

Namespace
Breeze.AspNetCore
Assembly
Breeze.AspNetCore.NetCore.dll

Static utility functions for processing queries

public static class QueryFns
Inheritance
QueryFns
Inherited Members

Fields

skipFlag

Flag on HttpContext.Items to indicate that BreezeQueryFilter processing should be skipped.

public static readonly string skipFlag

Field Value

string

Methods

ApplyBreezeQuery<T>(ActionContext, IQueryable<T>)

Apply the Where, Order, Skip, and Take predicates from the request's query string to the IQueryable

public static IQueryable<T> ApplyBreezeQuery<T>(ActionContext context, IQueryable<T> queryable)

Parameters

context ActionContext
queryable IQueryable<T>

Returns

IQueryable<T>

Type Parameters

T

Remarks

Example: Apply query filtering, then aggregate the results.

<pre><code class="lang-csharp">// Apply EntityQuery to filter the IQueryable before aggregation

var query = QueryFns.ApplyBreezeQuery(this.ControllerContext, dbContext.Orders); // Total the results var totals = query.Sum(o => o.TotalAmount).ToList(); // Return an object, not an IEnumerable, else Breeze will attempt to apply the query again return new { total = totals[0] };

ApplyBreezeQuery<T>(ControllerBase, IQueryable<T>)

Apply the Where, Order, Skip, and Take predicates from the request's query string (or POST body) to the IQueryable

public static IQueryable<T> ApplyBreezeQuery<T>(this ControllerBase controller, IQueryable<T> queryable)

Parameters

controller ControllerBase
queryable IQueryable<T>

Returns

IQueryable<T>

Type Parameters

T

Remarks

Example: Apply query filtering, then aggregate the results.

<pre><code class="lang-csharp">// Apply EntityQuery from client to filter the IQueryable before aggregation

var query = this.ApplyBreezeQuery(dbContext.Orders); // Total the results var totals = query.Sum(o => o.TotalAmount).ToList(); // Return an object, not an IEnumerable, else Breeze will attempt to apply the query again return new { total = totals[0] };

ApplyBreezeWhere<T>(ActionContext, IQueryable<T>)

Apply the Where predicate from the request's query string (or POST body) to the IQueryable

public static IQueryable<T> ApplyBreezeWhere<T>(ActionContext context, IQueryable<T> queryable)

Parameters

context ActionContext
queryable IQueryable<T>

Returns

IQueryable<T>

Type Parameters

T

Remarks

Example: Apply query Where clause, then aggregate the results.

<pre><code class="lang-csharp">// Apply Where clause from client to filter the IQueryable before aggregation

var query = QueryFns.ApplyBreezeWhere(this.ControllerContext, dbContext.Orders); // Total the results var totals = query.Sum(o => o.TotalAmount).ToList(); // Return an object, not an IEnumerable, else Breeze will attempt to apply the query again return new { total = totals[0] };

ApplyBreezeWhere<T>(ControllerBase, IQueryable<T>)

Apply the Where predicate from the request's query string (or POST body) to the IQueryable

public static IQueryable<T> ApplyBreezeWhere<T>(this ControllerBase controller, IQueryable<T> queryable)

Parameters

controller ControllerBase
queryable IQueryable<T>

Returns

IQueryable<T>

Type Parameters

T

Remarks

Example: Apply query filtering, then aggregate the results.

<pre><code class="lang-csharp">// Apply Where clause from client to filter the IQueryable before aggregation

var query = this.ApplyBreezeWhere(dbContext.Orders); // Total the results var totals = query.Sum(o => o.TotalAmount).ToList(); // Return an object, not an IEnumerable, else Breeze will attempt to apply the query again return new { total = totals[0] };

ExtractAndDecodeQueryString(ActionContext, bool)

Get the query string OR request body from the HttpRequest

public static string? ExtractAndDecodeQueryString(ActionContext context, bool usePost = false)

Parameters

context ActionContext

Contains HttpContext

usePost bool

If true and request is POST, then attempt to extract the Breeze query from the request body.

Returns

string

ExtractQueryable(ActionExecutedContext, bool)

Get the IQueryable from the context.Result

public static IQueryable? ExtractQueryable(ActionExecutedContext context, bool throwOnError = false)

Parameters

context ActionExecutedContext
throwOnError bool

Returns

IQueryable

ExtractRequestBody(ActionContext)

Get the request body from the HttpRequest

public static string? ExtractRequestBody(ActionContext context)

Parameters

context ActionContext

Returns

string

IsSkipBreezeQueryFilter(ActionContext)

Set the flag to skip BreezeQueryFilter processing for this request.

public static bool IsSkipBreezeQueryFilter(ActionContext context)

Parameters

context ActionContext

Returns

bool

SkipBreezeQueryFilter(ActionContext, bool)

Set the flag to skip BreezeQueryFilter processing for this request.

public static void SkipBreezeQueryFilter(ActionContext context, bool skip = true)

Parameters

context ActionContext
skip bool

SkipBreezeQueryFilter(ControllerBase, bool)

Set the flag to skip BreezeQueryFilter processing for this request.

public static void SkipBreezeQueryFilter(this ControllerBase controller, bool skip = true)

Parameters

controller ControllerBase
skip bool