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
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
contextActionContextqueryableIQueryable<T>
Returns
- IQueryable<T>
Type Parameters
T
Remarks
<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
controllerControllerBasequeryableIQueryable<T>
Returns
- IQueryable<T>
Type Parameters
T
Remarks
<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
contextActionContextqueryableIQueryable<T>
Returns
- IQueryable<T>
Type Parameters
T
Remarks
<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
controllerControllerBasequeryableIQueryable<T>
Returns
- IQueryable<T>
Type Parameters
T
Remarks
<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
contextActionContextContains HttpContext
usePostboolIf true and request is POST, then attempt to extract the Breeze query from the request body.
Returns
ExtractQueryable(ActionExecutedContext, bool)
Get the IQueryable from the context.Result
public static IQueryable? ExtractQueryable(ActionExecutedContext context, bool throwOnError = false)
Parameters
contextActionExecutedContextthrowOnErrorbool
Returns
ExtractRequestBody(ActionContext)
Get the request body from the HttpRequest
public static string? ExtractRequestBody(ActionContext context)
Parameters
contextActionContext
Returns
IsSkipBreezeQueryFilter(ActionContext)
Set the flag to skip BreezeQueryFilter processing for this request.
public static bool IsSkipBreezeQueryFilter(ActionContext context)
Parameters
contextActionContext
Returns
SkipBreezeQueryFilter(ActionContext, bool)
Set the flag to skip BreezeQueryFilter processing for this request.
public static void SkipBreezeQueryFilter(ActionContext context, bool skip = true)
Parameters
contextActionContextskipbool
SkipBreezeQueryFilter(ControllerBase, bool)
Set the flag to skip BreezeQueryFilter processing for this request.
public static void SkipBreezeQueryFilter(this ControllerBase controller, bool skip = true)
Parameters
controllerControllerBaseskipbool