Repository navigation
OnixLabs.Core.Linq.IQueryableExtensions
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
|
[EditorBrowsable(EditorBrowsableState.Never)]
public static class IQueryableExtensionsNote
IQueryableExtensionsis decorated with[EditorBrowsable(EditorBrowsableState.Never)]. Although the class ispublic, it is hidden from IntelliSense completion lists so that only the extension methods themselves appear on their receiver types. Bring the extensions into scope withusing 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 athisparameter. The signatures shown below are the call-site signatures as consumed by user code.
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.
| Method | Returns | Description |
|---|---|---|
Where(Specification<T>) |
IQueryable<T> |
Filters by a specification. |
WhereNot(Specification<T>) |
IQueryable<T> |
Filters by a negated specification. |
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);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. |
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. |
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions