Skip to content

OnixLabs.Core.Linq.IQueryableExtensions

matthew edited this page May 27, 2026 · 1 revision

IQueryableExtensions Class

Provides LINQ-like extension methods for IQueryable<T> instances, enabling specification-based filtering that can be translated by query providers such as Entity Framework.

Namespace OnixLabs.Core.Linq
Assembly OnixLabs.Core.dll (NuGet)
Inheritance object → IQueryableExtensions

Definition

[EditorBrowsable(EditorBrowsableState.Never)]
public static class IQueryableExtensions

Note IQueryableExtensions is decorated with [EditorBrowsable(EditorBrowsableState.Never)]. Although the class is public, it is hidden from IntelliSense completion lists so that only the extension methods themselves appear on their receiver types. Bring the extensions into scope with using OnixLabs.Core.Linq;.

This class uses a C# 14 extension block (extension<T>(IQueryable<T> queryable) { ... }), so the receiver type appears in the block declaration rather than as a this parameter. The signatures shown below are the call-site signatures as consumed by user code.

Remarks

These extensions filter a queryable source using the Specification<T> pattern. Because they pass the specification's Criteria expression tree directly to the underlying provider (via IQueryable<T>.Where(Expression<Func<T, bool>>)), the filter can be translated to SQL or another query language by providers such as Entity Framework rather than evaluated in memory.

To compose complex filter criteria, combine specifications with their And, Or, and Not combinators — which in turn delegate to ExpressionExtensions — before passing the result to these methods.

For equivalent filtering over in-memory IEnumerable<T> sequences, see IEnumerableExtensions.

Methods

Method Returns Description
Where(Specification<T>) IQueryable<T> Filters by a specification.
WhereNot(Specification<T>) IQueryable<T> Filters by a negated specification.

Examples

using OnixLabs.Core;
using OnixLabs.Core.Linq;
using System.Linq;

Specification<Person> adults = new CriteriaSpecification<Person>(p => p.Age >= 18);

IQueryable<Person> query   = people.AsQueryable().Where(adults);
IQueryable<Person> minors  = people.AsQueryable().WhereNot(adults);

Where(Specification<T>)

public IQueryable<T> Where(Specification<T> specification)

Filters a sequence of values based on a Specification<T>, passing its Criteria expression to the query provider.

Parameter Type Description
specification Specification<T> The specification to filter by.

Returns — An IQueryable<T> containing elements that satisfy the specification.

Exceptions

Exception Condition
ArgumentNullException The current IQueryable<T> or specification is null.

WhereNot(Specification<T>)

public IQueryable<T> WhereNot(Specification<T> specification)

Filters a sequence of values based on a negated Specification<T>, passing the negated Criteria expression to the query provider.

Parameter Type Description
specification Specification<T> The specification to filter by.

Returns — An IQueryable<T> containing elements that satisfy the negated specification.

Exceptions

Exception Condition
ArgumentNullException The current IQueryable<T> or specification is null.

See Also

ONIXLabs .NET Library


Clone this wiki locally