Table of Contents

Class QueryExtensions

Namespace
NRules.Fluent.Dsl
Assembly
NRules.Fluent.dll
public static class QueryExtensions
Inheritance
QueryExtensions
Inherited Members

Methods

Collect<TSource>(IQuery<TSource>)

Aggregates matching facts into a collection.

public static ICollectQuery<IEnumerable<TSource>> Collect<TSource>(this IQuery<TSource> source)

Parameters

source IQuery<TSource>

Query expression builder.

Returns

ICollectQuery<IEnumerable<TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

From<TFact>(IQuery, Expression<Func<TFact>>)

Creates a query from a given expression.

public static IQuery<TFact> From<TFact>(this IQuery query, Expression<Func<TFact>> source)

Parameters

query IQuery

Query expression builder.

source Expression<Func<TFact>>

Expression that generates source facts.

Returns

IQuery<TFact>

Query expression builder.

Type Parameters

TFact

Type of facts to query.

GroupBy<TSource, TKey>(IQuery<TSource>, Expression<Func<TSource, TKey>>)

Aggregates source facts into groups based on a grouping key.

public static IQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IQuery<TSource> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source IQuery<TSource>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Grouping key selection expression.

Returns

IQuery<IGrouping<TKey, TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of grouping key.

GroupBy<TSource, TKey, TElement>(IQuery<TSource>, Expression<Func<TSource, TKey>>, Expression<Func<TSource, TElement>>)

Aggregates source facts into groups based on a grouping key. Projects facts as part of grouping based on a value selection expression.

public static IQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQuery<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)

Parameters

source IQuery<TSource>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Grouping key selection expression.

elementSelector Expression<Func<TSource, TElement>>

Projected fact selection expression.

Returns

IQuery<IGrouping<TKey, TElement>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of grouping key.

TElement

Type of projected facts.

Match<TFact>(IQuery, params Expression<Func<TFact, bool>>[])

Creates a query from matching facts in the engine's working memory.

public static IQuery<TFact> Match<TFact>(this IQuery query, params Expression<Func<TFact, bool>>[] conditions)

Parameters

query IQuery

Query expression builder.

conditions Expression<Func<TFact, bool>>[]

Set of conditions the fact must satisfy.

Returns

IQuery<TFact>

Query expression builder.

Type Parameters

TFact

Type of facts to query.

OrderByDescending<TSource, TKey>(ICollectQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>)

Configures collected matching facts to be sorted descending by key.

public static IOrderedQuery<IEnumerable<TSource>> OrderByDescending<TSource, TKey>(this ICollectQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source ICollectQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Key selection expression used for sorting.

Returns

IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of sorting key.

OrderBy<TSource, TKey>(ICollectQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>)

Configures collected matching facts to be sorted ascending by key.

public static IOrderedQuery<IEnumerable<TSource>> OrderBy<TSource, TKey>(this ICollectQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source ICollectQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Key selection expression used for sorting.

Returns

IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of sorting key.

SelectMany<TSource, TResult>(IQuery<TSource>, Expression<Func<TSource, IEnumerable<TResult>>>)

Flattens source facts using collection selector expression.

public static IQuery<TResult> SelectMany<TSource, TResult>(this IQuery<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)

Parameters

source IQuery<TSource>

Query expression builder.

selector Expression<Func<TSource, IEnumerable<TResult>>>

Collection flattening expression.

Returns

IQuery<TResult>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TResult

Type of flattened facts.

Select<TSource, TResult>(IQuery<TSource>, Expression<Func<TSource, TResult>>)

Projects source facts using selector expression.

public static IQuery<TResult> Select<TSource, TResult>(this IQuery<TSource> source, Expression<Func<TSource, TResult>> selector)

Parameters

source IQuery<TSource>

Query expression builder.

selector Expression<Func<TSource, TResult>>

Projection expression.

Returns

IQuery<TResult>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TResult

Type of projected facts.

ThenByDescending<TSource, TKey>(IOrderedQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>)

Configures sorted matching facts to subsequently be sorted descending by key.

public static IOrderedQuery<IEnumerable<TSource>> ThenByDescending<TSource, TKey>(this IOrderedQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Key selection expression used for sorting.

Returns

IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of sorting key.

ThenBy<TSource, TKey>(IOrderedQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>)

Configures sorted matching facts to subsequently be sorted ascending by key.

public static IOrderedQuery<IEnumerable<TSource>> ThenBy<TSource, TKey>(this IOrderedQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Key selection expression used for sorting.

Returns

IOrderedQuery<IEnumerable<TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of sorting key.

ToLookup<TSource>(ICollectQuery<IEnumerable<TSource>>)

Configures collected matching facts to be arranged into a lookup keyed on the fact itself.

public static IQuery<IKeyedLookup<TSource, TSource>> ToLookup<TSource>(this ICollectQuery<IEnumerable<TSource>> source)

Parameters

source ICollectQuery<IEnumerable<TSource>>

Query expression builder.

Returns

IQuery<IKeyedLookup<TSource, TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

ToLookup<TSource, TKey>(ICollectQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>)

Configures collected matching facts to be arranged into a lookup based on a grouping key.

public static IQuery<IKeyedLookup<TKey, TSource>> ToLookup<TSource, TKey>(this ICollectQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source ICollectQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Grouping key selection expression.

Returns

IQuery<IKeyedLookup<TKey, TSource>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of grouping key.

ToLookup<TSource, TKey, TElement>(ICollectQuery<IEnumerable<TSource>>, Expression<Func<TSource, TKey>>, Expression<Func<TSource, TElement>>)

Configures collected matching facts to be arranged into a lookup based on a grouping key. Projects facts collected into a lookup based on a value selection expression.

public static IQuery<IKeyedLookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this ICollectQuery<IEnumerable<TSource>> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)

Parameters

source ICollectQuery<IEnumerable<TSource>>

Query expression builder.

keySelector Expression<Func<TSource, TKey>>

Grouping key selection expression.

elementSelector Expression<Func<TSource, TElement>>

Projected fact selection expression.

Returns

IQuery<IKeyedLookup<TKey, TElement>>

Query expression builder.

Type Parameters

TSource

Type of source facts.

TKey

Type of grouping key.

TElement

Type of projected facts.

Where<TSource>(IQuery<TSource>, params Expression<Func<TSource, bool>>[])

Filters source facts using a set of predicate expressions. The facts must match all predicate expressions in order to pass the filter.

public static IQuery<TSource> Where<TSource>(this IQuery<TSource> source, params Expression<Func<TSource, bool>>[] predicates)

Parameters

source IQuery<TSource>

Query expression builder.

predicates Expression<Func<TSource, bool>>[]

Filter expressions.

Returns

IQuery<TSource>

Query expression builder.

Type Parameters

TSource

Type of facts to filter.