Class NHQueryHelper
- Namespace
- Breeze.Persistence.NH
- Assembly
- Breeze.Persistence.NH.dll
Query helpers for NHibernate: an Include operator, and the hooks Breeze calls around query execution.
public static class NHQueryHelper
- Inheritance
-
NHQueryHelper
- Inherited Members
Methods
Include<TEntity>(IQueryable<TEntity>, string)
Record a navigation path to be loaded with the results, in the manner of Entity Framework's Include.
public static IQueryable<TEntity> Include<TEntity>(this IQueryable<TEntity> source, string navigationPropertyPath) where TEntity : class
Parameters
sourceIQueryable<TEntity>The query.
navigationPropertyPathstringThe navigation path to load, e.g. "Orders".
Returns
- IQueryable<TEntity>
A query carrying the recorded path; the original if its provider is not an NHibernate one.
Type Parameters
TEntityThe element type of the query.
Remarks
The path is not added to the expression tree - NHibernate's LINQ parser would reject it - but kept on the query provider and applied after the query runs. Unlike Fetch, this issues a second query rather than a join, which keeps the row count of the original query intact.
NeedsExecution(string?, IQueryable?)
Whether Breeze should execute the queryable itself, rather than leave it to the framework.
public static bool NeedsExecution(string? queryString, IQueryable? queryable)
Parameters
queryStringstringThe Breeze query string, or null if the request carried none.
queryableIQueryableThe queryable, or null if the action did not return one.
Returns
- bool
True when there is a queryable and either a query string or an NHibernate provider to run it with.
PostExecuteQuery(EntityQuery, IQueryable, IList)
After a query runs, load the expanded properties and close the session.
public static IList PostExecuteQuery(this EntityQuery eq, IQueryable queryable, IList result)
Parameters
eqEntityQueryThe query that was executed.
queryableIQueryableThe queryable it was executed against.
resultIListThe rows returned.
Returns
- IList
The same rows, with their expanded properties loaded.
Remarks
Lazy proxies must be resolved before the session closes, or serializing the results would fail. Paths come from both the query's expand clause and any Include<TEntity>(IQueryable<TEntity>, string) calls.