Referencia Pública de API .NETL1 Modelado de Dominio y ConsultasEstableAOT: Parcial

EricksonLopez.Specification

A high-performance, AOT-first, zero-reflection, zero-allocation specification pattern implementation for modern .NET, powered by Roslyn Incremental Source Generators

22 namespaces82 tipos365 miembrosGenerado desde XML docs y ensamblados · UTC 2026-12-01

Mostrando 82 de 82 tipos (365 miembros)

EricksonLopez.DapperExtensions.UnitOfWork#

1
interface

IUnitOfWork

Ensamblado: EricksonLopez.Specification.DapperExtensions
public interface IUnitOfWork

Defines the contract for an active unit of work that manages database transactions.

Miembros (1)

  • propertyTransaction
    IDbTransaction Transaction { get; }

    Gets the database transaction associated with this unit of work.

EricksonLopez.Specification#

20
class

CursorClause<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public sealed class CursorClause<T>

Represents a keyset cursor clause for pagination.

Notas:

Type parameters: T: The entity type.

Miembros (4)

  • constructorCursorClause
    public CursorClause(Expression<Func<T, object?>> keySelector, object? value, CursorDirection direction)

    Initializes a new instance of the `CursorClause<T>` class.

    keySelector: Expression<Func<T, object?>>
    The key selector expression.
    value: object?
    The cursor threshold value.
    direction: CursorDirection
    The seek direction.

    Exceptions: ArgumentNullException: `keySelector` is `null`

  • propertyDirection
    public CursorDirection Direction { get; }

    Gets the seek direction.

  • propertyKeySelector
    public Expression<Func<T, object?>> KeySelector { get; }

    Gets the key selector expression for the cursor.

  • propertyValue
    public object? Value { get; }

    Gets the cursor value to seek from.

enum

CursorDirection

Ensamblado: EricksonLopez.Specification.Abstractions
public enum CursorDirection

Specifies the seek direction for cursor-based (keyset) pagination.

Miembros (2)

  • fieldAfter
    After = 0

    Seeks records occurring after the cursor value.

  • fieldBefore
    Before = 1

    Seeks records occurring before the cursor value.

class

ExpressionCompilationCache

Ensamblado: EricksonLopez.Specification
public static class ExpressionCompilationCache

Provides a thread-safe bounded LRU (Least Recently Used) cache for compiled expression delegates, keyed by expression structural AST equality.

Notas:

Expression compilation via `Expression.Compile()` is an expensive operation that invokes the JIT compiler. This cache ensures that each structurally unique expression is compiled at most once per process, up to a configurable `Capacity` limit. When the capacity is reached, the least recently used delegates are evicted in O(1) time. AOT warning: This cache is only useful in JIT runtimes. All methods that return compiled delegates are annotated with `RequiresDynamicCodeAttribute` and will not work correctly under Native AOT. Cache key: The key is the `Expression` tree itself, compared via deep structural AST equality using `ExpressionEqualityComparer.Default`. This guarantees complete correctness and prevents delegate corruption from hash collisions.

Miembros (3)

  • methodGetOrCompile<T>
    public static Func<T, bool> GetOrCompile<T>(Expression<Func<T, bool>> expression)

    Retrieves a compiled delegate for the given predicate expression, compiling it only if not already cached.

    expression: Expression<Func<T, bool>>
    The expression to compile.

    Retorna: A compiled delegate equivalent to the expression.

    Type parameters: T: The predicate input type. Exceptions: ArgumentNullException: `expression` is `null`

  • propertyCachedCount
    public static int CachedCount { get; }

    Gets the number of compiled delegates currently in the cache.

  • propertyCapacity
    public static int Capacity { get; internal set; }

    Gets or sets the maximum number of compiled delegates retained in the cache. Default is 512.

class

ExpressionComposer

Ensamblado: EricksonLopez.Specification
public static class ExpressionComposer

Provides efficient, provider-safe expression composition without `Expression.Invoke`. All compositions inline the right-hand expression body using parameter rebinding.

Notas:

The fundamental constraint this engine satisfies: no composed expression tree should contain an `InvocationExpression`. EF Core's query translator and most SQL translators do not support `Expression.Invoke`, and its presence causes client-side evaluation or translation failures. All methods are allocation-minimal: they create exactly the new expression nodes required (a parameter expression reuse, a binary node, and the lambda wrapper).

Miembros (6)

  • methodAnd<T>
    public static Expression<Func<T, bool>> And<T>(Expression<Func<T, bool>> left, Expression<Func<T, bool>> right)

    Combines two predicate expressions with a logical AND. Equivalent to: `x => left(x) && right(x)`.

    left: Expression<Func<T, bool>>
    The left-hand predicate.
    right: Expression<Func<T, bool>>
    The right-hand predicate.

    Retorna: A new expression that is the logical AND of both predicates.

    Type parameters: T: The input type of both predicates. Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodAndAll<T>
    public static Expression<Func<T, bool>> AndAll<T>(ReadOnlySpan<Expression<Func<T, bool>>> predicates)

    Combines an array of predicate expressions with logical AND. All predicates share the same parameter after composition.

    predicates: ReadOnlySpan<Expression<Func<T, bool>>>
    The predicates to combine. Must not be empty.

    Retorna: A single expression representing the logical AND of all predicates.

    Type parameters: T: The input type of all predicates. Exceptions: ArgumentException: `predicates` is empty

  • methodNot<T>
    public static Expression<Func<T, bool>> Not<T>(Expression<Func<T, bool>> predicate)

    Negates a predicate expression. Equivalent to: `x => !predicate(x)`.

    predicate: Expression<Func<T, bool>>
    The predicate to negate.

    Retorna: A new expression that is the logical NOT of the predicate.

    Type parameters: T: The input type of the predicate. Exceptions: ArgumentNullException: `predicate` is `null`

  • methodOr<T>
    public static Expression<Func<T, bool>> Or<T>(Expression<Func<T, bool>> left, Expression<Func<T, bool>> right)

    Combines two predicate expressions using logical OR with parameter rebinding.

    left: Expression<Func<T, bool>>
    The left operand expression.
    right: Expression<Func<T, bool>>
    The right operand expression.

    Retorna: A new expression representing `left OR right`.

    Type parameters: T: The predicate parameter type. Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodOrAny<T>
    public static Expression<Func<T, bool>> OrAny<T>(ReadOnlySpan<Expression<Func<T, bool>>> predicates)

    Combines an array of predicate expressions with logical OR. All predicates share the same parameter after composition.

    predicates: ReadOnlySpan<Expression<Func<T, bool>>>
    The predicates to combine. Must not be empty.

    Retorna: A single expression representing the logical OR of all predicates.

    Type parameters: T: The input type of all predicates. Exceptions: ArgumentException: `predicates` is empty

  • fieldMaxDepth
    public const int MaxDepth

    Specifies the maximum supported depth for composed expression trees to prevent recursion depth exhaustion.

class

ExpressionDebugFormatterRegistry

Ensamblado: EricksonLopez.Specification.Abstractions
public static class ExpressionDebugFormatterRegistry

Provides a registry for expression debug formatting across architectural layers.

Miembros (2)

  • methodFormat
    public static string Format(Expression expression)

    Formats an expression using the registered formatter.

    expression: Expression
    The expression to format.

    Retorna: A formatted string representation of the expression.

    Exceptions: ArgumentNullException: `expression` is `null`

  • propertyFormatter
    public static Func<Expression, string> Formatter { get; set; }

    Gets or sets the debug formatter delegate.

class

ExpressionInterpreter

Ensamblado: EricksonLopez.Specification
public static class ExpressionInterpreter

Provides an AOT-safe interpreted evaluator for domain predicate expressions.

Notas:

This evaluator supports expression node types commonly used in domain specifications: member access, constant comparisons, binary operators (and, or, coalesce, equality, comparison), unary operators (not, convert), conditional ternary expressions, type binary tests (`is`), and method calls.

Miembros (1)

  • methodEvaluate<T>
    public static bool Evaluate<T>(Expression<Func<T, bool>> expression, T candidate)

    Evaluates whether a predicate expression is satisfied by a candidate value without runtime IL compilation.

    expression: Expression<Func<T, bool>>
    The predicate expression to evaluate.
    candidate: T
    The candidate value to test.

    Retorna: `true` if the candidate satisfies the expression; otherwise, `false`.

    In Native AOT scenarios where specifications traverse nested properties (e.g., c => c.Address.City), ensure intermediate property types are also annotated with `DynamicallyAccessedMembersAttribute` or preserved in TrimmerRoots.xml. Type parameters: T: The candidate type. Exceptions: ArgumentNullException: `expression` or `candidate` is `null`

class

FullTextExtensions

Ensamblado: EricksonLopez.Specification
public static class FullTextExtensions

Provides extension methods for full-text search expressions.

Miembros (1)

  • methodMatchesFullText
    public static bool MatchesFullText(this string? value, string query)

    Evaluates whether the string contains the specified full-text search query.

    value: this string?
    The string value to evaluate.
    query: string
    The search terms to match.

    Retorna: `true` if `value` matches the search query; otherwise, `false`.

interface

IExpressionSpecification<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public interface IExpressionSpecification<T> : ISpecification<T>
Implementa: ISpecification<T>

Defines a specification that can be converted to an expression tree for query providers.

Notas:

Type parameters: T: The entity type evaluated by this specification.

Miembros (3)

  • methodToCompiledPredicate
    Func<T, bool> ToCompiledPredicate()

    Compiles or retrieves the cached predicate delegate for this specification expression.

    Retorna: A compiled predicate delegate.

  • methodToDebugString
    string ToDebugString()

    Returns a human-readable string representation of this specification's expression.

    Retorna: A string representation of the specification expression.

    The default implementation delegates to `ExpressionDebugFormatterRegistry`.

  • methodToExpression
    Expression<Func<T, bool>> ToExpression()

    Converts this specification to a LINQ expression tree.

    Retorna: An expression tree representing the specification predicate.

interface

IOrderClause<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public interface IOrderClause<T>

Defines an ordering clause for entity queries.

Notas:

Type parameters: T: The entity type being ordered.

Miembros (4)

  • methodApplyOrderBy
    IOrderedQueryable<T> ApplyOrderBy(IQueryable<T> query)

    Applies primary ordering to a queryable.

    query: IQueryable<T>
  • methodApplyThenBy
    IOrderedQueryable<T> ApplyThenBy(IOrderedQueryable<T> query)

    Applies secondary ordering to an ordered queryable.

    query: IOrderedQueryable<T>
  • propertyDirection
    OrderDirection Direction { get; }

    Gets the ordering direction.

  • propertyKeySelector
    LambdaExpression KeySelector { get; }

    Gets the untyped lambda key selector expression.

interface

IReadRepository<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public interface IReadRepository<T>

Defines a read-only repository contract that operates on `QuerySpec<T>` descriptors. Implementations translate specifications to provider-specific queries.

Notas:

Type parameters: T: The entity type managed by this repository.

Miembros (7)

  • methodAnyAsync
    Task<bool> AnyAsync(QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Determines whether any entity matches the specification.

    specification: QuerySpec<T>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains `true` if at least one entity matches; otherwise, `false`.

  • methodCountAsync
    Task<int> CountAsync(QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Calculates the number of entities matching the specification.

    specification: QuerySpec<T>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the count of matching entities.

  • methodFirstOrDefaultAsync
    Task<T?> FirstOrDefaultAsync(QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves the first entity matching the specification, or `null` if none found.

    specification: QuerySpec<T>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the first matching entity, or `null` if not found.

  • methodGetByIdAsync<TId>
    Task<T?> GetByIdAsync<TId>(TId id, CancellationToken cancellationToken = default) where TId : notnull

    Retrieves an entity by its identifier.

    id: TId
    The entity identifier.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the matching entity, or `null` if not found.

    The default interface implementation throws `NotSupportedException`. Implementors must override this method to provide actual entity lookup by identifier. Type parameters: TId: The identifier type.

  • methodListAsync
    Task<IReadOnlyList<T>> ListAsync(QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves all entities matching the specification.

    specification: QuerySpec<T>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a read-only list of matching entities.

  • methodListAsync<TResult>
    Task<IReadOnlyList<TResult>> ListAsync<TResult>(QuerySpec<T, TResult> specification, CancellationToken cancellationToken = default)

    Retrieves projected results for entities matching the specification.

    specification: QuerySpec<T, TResult>
    The query specification with projection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a read-only list of projected results.

    Type parameters: TResult: The projected result type.

  • methodSingleOrDefaultAsync
    Task<T?> SingleOrDefaultAsync(QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves the single entity matching the specification, or `null` if none found.

    specification: QuerySpec<T>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the single matching entity, or `null` if not found.

    Exceptions: InvalidOperationException: More than one entity matches the specification

interface

ISpecification<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public interface ISpecification<T>

Defines a domain-level specification used to evaluate whether a candidate satisfies business criteria.

Notas:

Represents a minimal and AOT-safe specification contract, providing in-memory rule evaluation without external persistence dependencies. Type parameters: T: The type of candidate being evaluated.

Miembros (4)

  • methodAnd
    ISpecification<T> And(ISpecification<T> other)

    Composes this specification with another using logical AND.

    other: ISpecification<T>
    The other specification to compose with.

    Retorna: A composite specification that is satisfied when both specifications are satisfied.

    Exceptions: ArgumentNullException: `other` is `null`

  • methodIsSatisfiedBy
    bool IsSatisfiedBy(T candidate)

    Determines whether the specified `candidate` satisfies this specification.

    candidate: T
    The candidate to evaluate.

    Retorna: `true` if the candidate satisfies the specification; otherwise, `false`.

    Exceptions: ArgumentNullException: `candidate` is `null`

  • methodNot
    ISpecification<T> Not()

    Inverts this specification using logical NOT.

    Retorna: A composite specification that is satisfied when this specification is not satisfied.

  • methodOr
    ISpecification<T> Or(ISpecification<T> other)

    Composes this specification with another using logical OR.

    other: ISpecification<T>
    The other specification to compose with.

    Retorna: A composite specification that is satisfied when either specification is satisfied.

    Exceptions: ArgumentNullException: `other` is `null`

class

OrderClause<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public sealed class OrderClause<T> : IOrderClause<T>
Implementa: IOrderClause<T>

Untyped ordering clause retained for backward compatibility.

Notas:

Type parameters: T: The entity type being ordered.

Miembros (5)

  • constructorOrderClause
    public OrderClause(Expression<Func<T, object?>> keySelector, OrderDirection direction)

    Initializes a new instance of the `OrderClause<T>` class.

    keySelector: Expression<Func<T, object?>>
    The key selector expression.
    direction: OrderDirection
    The ordering direction.

    Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodApplyOrderBy
    public IOrderedQueryable<T> ApplyOrderBy(IQueryable<T> query)

    Applies primary ordering to a queryable.

    query: IQueryable<T>
  • methodApplyThenBy
    public IOrderedQueryable<T> ApplyThenBy(IOrderedQueryable<T> query)

    Applies secondary ordering to an ordered queryable.

    query: IOrderedQueryable<T>
  • propertyDirection
    public OrderDirection Direction { get; }

    Gets the ordering direction.

  • propertyKeySelector
    public Expression<Func<T, object?>> KeySelector { get; }

    Gets the key selector expression for ordering.

class

OrderClause<T, TKey>

Ensamblado: EricksonLopez.Specification.Abstractions
public sealed class OrderClause<T, TKey> : IOrderClause<T>
Implementa: IOrderClause<T>

Strongly-typed ordering clause preserving key type without heap boxing.

Notas:

Type parameters: T: The entity type being ordered.; TKey: The type of the ordering key.

Miembros (5)

  • constructorOrderClause
    public OrderClause(Expression<Func<T, TKey>> keySelector, OrderDirection direction)

    Initializes a new instance of the `OrderClause<T, TKey>` class.

    keySelector: Expression<Func<T, TKey>>
    The strongly-typed key selector expression.
    direction: OrderDirection
    The ordering direction.

    Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodApplyOrderBy
    public IOrderedQueryable<T> ApplyOrderBy(IQueryable<T> query)

    Applies primary ordering to a queryable.

    query: IQueryable<T>
  • methodApplyThenBy
    public IOrderedQueryable<T> ApplyThenBy(IOrderedQueryable<T> query)

    Applies secondary ordering to an ordered queryable.

    query: IOrderedQueryable<T>
  • propertyDirection
    public OrderDirection Direction { get; }

    Gets the ordering direction.

  • propertyKeySelector
    public Expression<Func<T, TKey>> KeySelector { get; }

    Gets the strongly-typed key selector expression.

enum

OrderDirection

Ensamblado: EricksonLopez.Specification.Abstractions
public enum OrderDirection

Specifies the ordering direction for a query specification order clause.

Miembros (2)

  • fieldAscending
    Ascending = 0

    Orders results in ascending order, from smallest to largest.

  • fieldDescending
    Descending = 1

    Orders results in descending order, from largest to smallest.

class

QuerySpecExtensions

Ensamblado: EricksonLopez.Specification
public static class QuerySpecExtensions

Provides extension methods for combining and working with `QuerySpec<T>` instances.

Miembros (12)

  • methodAnd<T, TResult>
    public static QuerySpec<T, TResult> And<T, TResult>(this QuerySpec<T, TResult> querySpec, Specification<T> specification)

    Combines a projected query specification with a domain specification using logical AND.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification to extend.
    specification: Specification<T>
    The domain specification to apply.

    Retorna: A new projected query specification with the specification predicate appended.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` or `specification` is `null`

  • methodAnd<T>
    public static QuerySpec<T> And<T>(this QuerySpec<T> querySpec, Specification<T> specification)

    Combines a query specification with a domain specification using logical AND.

    querySpec: this QuerySpec<T>
    The query specification to extend.
    specification: Specification<T>
    The domain specification to apply.

    Retorna: A new query specification with the specification predicate appended.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` or `specification` is `null`

  • methodBuildCombinedPredicate<T, TResult>
    public static Expression<Func<T, bool>>? BuildCombinedPredicate<T, TResult>(this QuerySpec<T, TResult> querySpec)

    Combines all criteria in the projected specification into a single composed AND predicate.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification.

    Retorna: A combined AND predicate, or `null` if no criteria exist.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodBuildCombinedPredicate<T>
    public static Expression<Func<T, bool>>? BuildCombinedPredicate<T>(this QuerySpec<T> querySpec)

    Combines all criteria in the specification into a single composed AND predicate.

    querySpec: this QuerySpec<T>
    The query specification.

    Retorna: A combined AND predicate, or `null` if no criteria exist.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasCriteria<T, TResult>
    public static bool HasCriteria<T, TResult>(this QuerySpec<T, TResult> querySpec)

    Determines whether the projected query specification has any filter criteria.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification to inspect.

    Retorna: `true` if at least one filter predicate is defined; otherwise, `false`.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasCriteria<T>
    public static bool HasCriteria<T>(this QuerySpec<T> querySpec)

    Determines whether the query specification has any filter criteria.

    querySpec: this QuerySpec<T>
    The query specification to inspect.

    Retorna: `true` if at least one filter predicate is defined; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasOrdering<T, TResult>
    public static bool HasOrdering<T, TResult>(this QuerySpec<T, TResult> querySpec)

    Determines whether the projected query specification has any ordering defined.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification to inspect.

    Retorna: `true` if at least one ordering clause is defined; otherwise, `false`.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasOrdering<T>
    public static bool HasOrdering<T>(this QuerySpec<T> querySpec)

    Determines whether the query specification has any ordering defined.

    querySpec: this QuerySpec<T>
    The query specification to inspect.

    Retorna: `true` if at least one ordering clause is defined; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasPagination<T, TResult>
    public static bool HasPagination<T, TResult>(this QuerySpec<T, TResult> querySpec)

    Determines whether the projected query specification has pagination defined.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification to inspect.

    Retorna: `true` if a skip or take count is defined; otherwise, `false`.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodHasPagination<T>
    public static bool HasPagination<T>(this QuerySpec<T> querySpec)

    Determines whether the query specification has pagination defined.

    querySpec: this QuerySpec<T>
    The query specification to inspect.

    Retorna: `true` if a skip or take count is defined; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodWhere<T, TResult>
    public static QuerySpec<T, TResult> Where<T, TResult>(this QuerySpec<T, TResult> querySpec, IExpressionSpecification<T> specification)

    Adds a domain specification predicate as an AND filter to the projected query specification.

    querySpec: this QuerySpec<T, TResult>
    The projected query specification to extend.
    specification: IExpressionSpecification<T>
    The domain specification to apply as a filter.

    Retorna: A new projected query specification with the specification predicate appended.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `querySpec` or `specification` is `null`

  • methodWhere<T>
    public static QuerySpec<T> Where<T>(this QuerySpec<T> querySpec, IExpressionSpecification<T> specification)

    Adds a domain specification predicate as an AND filter to the query specification.

    querySpec: this QuerySpec<T>
    The query specification to extend.
    specification: IExpressionSpecification<T>
    The domain specification to apply as a filter.

    Retorna: A new query specification with the specification predicate appended.

    This overload accepts any `IExpressionSpecification<T>` allowing both `Specification<T>` subclasses and lambda-based specifications created via `Spec.For<T>` to be used interchangeably with `.Where()` syntax. Type parameters: T: The entity type. Exceptions: ArgumentNullException: `querySpec` or `specification` is `null`

record

QuerySpec<T>

Ensamblado: EricksonLopez.Specification.Abstractions
public sealed record QuerySpec<T>

Represents an immutable query specification descriptor defining criteria, ordering, and pagination for entities of type `T`.

Notas:

This type is immutable and thread-safe. Combinator methods return a new instance without mutating the original. Type parameters: T: The entity type being queried.

Miembros (22)

  • methodDistinct
    public QuerySpec<T> Distinct()

    Creates a new `QuerySpec<T>` that eliminates duplicate results.

    Retorna: A new specification with distinct enabled.

  • methodOrderBy<TKey>
    public QuerySpec<T> OrderBy<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T>` with an ascending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodOrderByDescending<TKey>
    public QuerySpec<T> OrderByDescending<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T>` with a descending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodPage
    public QuerySpec<T> Page(int page, int pageSize)

    Creates a new `QuerySpec<T>` with offset-based pagination applied.

    page: int
    The 1-based page number.
    pageSize: int
    The number of records per page. Must be positive.

    Retorna: A new specification with pagination applied.

    Exceptions: ArgumentOutOfRangeException: `page` or `pageSize` is less than 1

  • methodSearch
    public QuerySpec<T> Search(string searchPhrase, params Expression<Func<T, string?>>[] propertySelectors)

    Creates a new `QuerySpec<T>` with a search filter across one or more string properties using logical OR.

    searchPhrase: string
    The search term to look for. The comparison is case-sensitive (uses `string.Contains(string)`).
    propertySelectors: params Expression<Func<T, string?>>[]
    The string property selectors to search within.

    Retorna: A new specification with the search criteria applied.

    The search uses `string.Contains(searchPhrase)` which is case-sensitive. For case-insensitive search, normalize the search phrase and property value to the same case before calling this method, or apply a provider-specific approach (e.g., `EF.Functions.Like`). Exceptions: ArgumentNullException: `searchPhrase`, `propertySelectors`, or any element of `propertySelectors` is `null`; ArgumentException: `propertySelectors` is empty

  • methodSeekAfter<TKey>
    public QuerySpec<T> SeekAfter<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)

    Creates a new specification configured for keyset pagination seeking records after the specified cursor.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value to seek after.
    take: int
    The number of records to return.

    Retorna: A new specification with the cursor and limit applied.

    Type parameters: TKey: The type of the cursor key.

  • methodSeekBefore<TKey>
    public QuerySpec<T> SeekBefore<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)

    Creates a new specification configured for keyset pagination seeking records before the specified cursor.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value to seek before.
    take: int
    The number of records to return.

    Retorna: A new specification with the cursor and limit applied.

    Type parameters: TKey: The type of the cursor key.

  • methodSkip
    public QuerySpec<T> Skip(int count)

    Creates a new `QuerySpec<T>` that skips the first `count` records.

    count: int
    The number of records to skip. Must be non-negative.

    Retorna: A new specification with the skip count applied.

    Exceptions: ArgumentOutOfRangeException: `count` is negative

  • methodTagWith
    public QuerySpec<T> TagWith(string tag)

    Creates a new `QuerySpec<T>` with the specified diagnostic query tag applied.

    tag: string
    The diagnostic query tag or comment.

    Retorna: A new specification with the tag applied.

    Exceptions: ArgumentException: `tag` is `null` or whitespace

  • methodTake
    public QuerySpec<T> Take(int count)

    Creates a new `QuerySpec<T>` that returns at most `count` records.

    count: int
    The maximum number of records to return. Must be positive.

    Retorna: A new specification with the take count applied.

    Exceptions: ArgumentOutOfRangeException: `count` is less than 1

  • methodThenBy<TKey>
    public QuerySpec<T> ThenBy<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T>` with a secondary ascending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the secondary ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodThenByDescending<TKey>
    public QuerySpec<T> ThenByDescending<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T>` with a secondary descending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the secondary ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodWhere
    public QuerySpec<T> Where(Expression<Func<T, bool>> predicate)

    Creates a new `QuerySpec<T>` with an additional AND predicate.

    predicate: Expression<Func<T, bool>>
    The predicate to add.

    Retorna: A new specification with the predicate appended to criteria.

    Exceptions: ArgumentNullException: `predicate` is `null`

  • methodWithCursor<TKey>
    public QuerySpec<T> WithCursor<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, CursorDirection direction, int take)

    Creates a new specification with keyset pagination applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value.
    direction: CursorDirection
    The seek direction.
    take: int
    The maximum number of records to return.

    Retorna: A new specification with keyset pagination applied.

    Type parameters: TKey: The type of the cursor key. Exceptions: ArgumentNullException: `keySelector` is `null`; ArgumentOutOfRangeException: `take` is less than 1

  • propertyCriteria
    public ImmutableArray<Expression<Func<T, bool>>> Criteria { get; init; }

    Gets the filter predicates combined using logical AND.

  • propertyCursor
    public CursorClause<T>? Cursor { get; init; }

    Gets the cursor clause for keyset pagination, if configured.

  • propertyIsDistinct
    public bool IsDistinct { get; init; }

    Gets a value indicating whether duplicate results should be eliminated.

  • propertyOrderClauses
    public ImmutableArray<IOrderClause<T>> OrderClauses { get; init; }

    Gets the ordering clauses applied in sequence.

  • propertySkipCount
    public int? SkipCount { get; init; }

    Gets the number of records to skip for offset-based pagination.

  • propertyTag
    public string? Tag { get; init; }

    Gets the diagnostic query tag or comment, if configured.

  • propertyTakeCount
    public int? TakeCount { get; init; }

    Gets the maximum number of records to return.

  • fieldEmpty
    public static readonly QuerySpec<T> Empty

    Gets an empty specification with no constraints.

record

QuerySpec<T, TResult>

Ensamblado: EricksonLopez.Specification.Abstractions
public sealed record QuerySpec<T, TResult>

Represents an immutable query specification descriptor defining criteria, ordering, pagination, and projection from `T` to `TResult`.

Notas:

This type is immutable and thread-safe. Combinator methods return a new instance without mutating the original. Type parameters: T: The source entity type.; TResult: The projected result type.

Miembros (24)

  • methodDistinct
    public QuerySpec<T, TResult> Distinct()

    Creates a new `QuerySpec<T, TResult>` that eliminates duplicate results.

    Retorna: A new specification with distinct enabled.

  • methodOrderBy<TKey>
    public QuerySpec<T, TResult> OrderBy<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T, TResult>` with an ascending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodOrderByDescending<TKey>
    public QuerySpec<T, TResult> OrderByDescending<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T, TResult>` with a descending order applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector.

    Retorna: A new specification with the ordering applied.

    Type parameters: TKey: The type of the ordering key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodPage
    public QuerySpec<T, TResult> Page(int page, int pageSize)

    Creates a new `QuerySpec<T, TResult>` with offset-based pagination applied.

    page: int
    The 1-based page number.
    pageSize: int
    The number of records per page. Must be positive.

    Retorna: A new specification with pagination applied.

    Exceptions: ArgumentOutOfRangeException: `page` or `pageSize` is less than 1

  • methodSearch
    public QuerySpec<T, TResult> Search(string searchPhrase, params Expression<Func<T, string?>>[] propertySelectors)

    Creates a new `QuerySpec<T, TResult>` with a search filter across one or more string properties using logical OR.

    searchPhrase: string
    The search term to look for.
    propertySelectors: params Expression<Func<T, string?>>[]
    The string property selectors to search within.

    Retorna: A new specification with the search criteria applied.

    Exceptions: ArgumentNullException: `searchPhrase`, `propertySelectors`, or any element of `propertySelectors` is `null`; ArgumentException: `propertySelectors` is empty

  • methodSeekAfter<TKey>
    public QuerySpec<T, TResult> SeekAfter<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)

    Creates a new specification configured for keyset pagination seeking records after the specified cursor.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value to seek after.
    take: int
    The number of records to return.

    Retorna: A new specification with the cursor and limit applied.

    Type parameters: TKey: The type of the cursor key.

  • methodSeekBefore<TKey>
    public QuerySpec<T, TResult> SeekBefore<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)

    Creates a new specification configured for keyset pagination seeking records before the specified cursor.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value to seek before.
    take: int
    The number of records to return.

    Retorna: A new specification with the cursor and limit applied.

    Type parameters: TKey: The type of the cursor key.

  • methodSelect
    public QuerySpec<T, TResult> Select(Expression<Func<T, TResult>> selector)

    Creates a new `QuerySpec<T, TResult>` with the specified projection.

    selector: Expression<Func<T, TResult>>
    The projection expression.

    Retorna: A new specification with the projection applied.

    Exceptions: ArgumentNullException: `selector` is `null`

  • methodSkip
    public QuerySpec<T, TResult> Skip(int count)

    Creates a new `QuerySpec<T, TResult>` that skips the first `count` records.

    count: int
    The number of records to skip. Must be non-negative.

    Retorna: A new specification with the skip count applied.

    Exceptions: ArgumentOutOfRangeException: `count` is negative

  • methodTagWith
    public QuerySpec<T, TResult> TagWith(string tag)

    Creates a new `QuerySpec<T, TResult>` with the specified diagnostic query tag applied.

    tag: string
    The diagnostic query tag or comment.

    Retorna: A new specification with the tag applied.

    Exceptions: ArgumentException: `tag` is `null` or whitespace

  • methodTake
    public QuerySpec<T, TResult> Take(int count)

    Creates a new `QuerySpec<T, TResult>` that returns at most `count` records.

    count: int
    The maximum number of records to return. Must be positive.

    Retorna: A new specification with the take count applied.

    Exceptions: ArgumentOutOfRangeException: `count` is less than 1

  • methodThenBy<TKey>
    public QuerySpec<T, TResult> ThenBy<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T, TResult>` with a secondary ascending order applied.

    keySelector: Expression<Func<T, TKey>>
    A function to extract a key from an element.

    Retorna: A new specification with the secondary ordering applied.

    Type parameters: TKey: The type of the sort key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodThenByDescending<TKey>
    public QuerySpec<T, TResult> ThenByDescending<TKey>(Expression<Func<T, TKey>> keySelector)

    Creates a new `QuerySpec<T, TResult>` with a secondary descending order applied.

    keySelector: Expression<Func<T, TKey>>
    A function to extract a key from an element.

    Retorna: A new specification with the secondary descending ordering applied.

    Type parameters: TKey: The type of the sort key. Exceptions: ArgumentNullException: `keySelector` is `null`

  • methodWhere
    public QuerySpec<T, TResult> Where(Expression<Func<T, bool>> predicate)

    Creates a new `QuerySpec<T, TResult>` with an additional AND predicate.

    predicate: Expression<Func<T, bool>>
    The predicate to add.

    Retorna: A new specification with the predicate appended to the criteria.

    Exceptions: ArgumentNullException: `predicate` is `null`

  • methodWithCursor<TKey>
    public QuerySpec<T, TResult> WithCursor<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, CursorDirection direction, int take)

    Creates a new specification with keyset pagination applied.

    keySelector: Expression<Func<T, TKey>>
    The key selector expression.
    cursorValue: TKey
    The cursor value.
    direction: CursorDirection
    The seek direction.
    take: int
    The maximum number of records to return.

    Retorna: A new specification with keyset pagination applied.

    Type parameters: TKey: The type of the cursor key. Exceptions: ArgumentNullException: `keySelector` is `null`; ArgumentOutOfRangeException: `take` is less than 1

  • propertyCriteria
    public ImmutableArray<Expression<Func<T, bool>>> Criteria { get; init; }

    Gets the filter predicates combined using logical AND.

  • propertyCursor
    public CursorClause<T>? Cursor { get; init; }

    Gets the cursor clause for keyset pagination, if configured.

  • propertyIsDistinct
    public bool IsDistinct { get; init; }

    Gets a value indicating whether duplicate results should be eliminated.

  • propertyOrderClauses
    public ImmutableArray<IOrderClause<T>> OrderClauses { get; init; }

    Gets the ordering clauses applied in sequence.

  • propertySelector
    public Expression<Func<T, TResult>>? Selector { get; init; }

    Gets the projection expression from `T` to `TResult`.

  • propertySkipCount
    public int? SkipCount { get; init; }

    Gets the number of records to skip for offset-based pagination.

  • propertyTag
    public string? Tag { get; init; }

    Gets the diagnostic query tag or comment, if configured.

  • propertyTakeCount
    public int? TakeCount { get; init; }

    Gets the maximum number of records to return.

  • fieldEmpty
    public static readonly QuerySpec<T, TResult> Empty

    Gets an empty specification with no constraints.

class

Spec

Ensamblado: EricksonLopez.Specification
public static class Spec

Provides factory methods for creating specifications from lambda expressions without subclassing.

Notas:

Use this factory for simple, one-off specifications. For reusable domain rules, prefer subclassing `Specification<T>` for better discoverability and naming.

Miembros (13)

  • methodAll<T>
    public static Specification<T> All<T>(IEnumerable<Specification<T>> specifications)

    Composes a sequence of specifications using logical AND.

    specifications: IEnumerable<Specification<T>>
    The specifications sequence to compose with AND.

    Retorna: A specification that is satisfied only when all of `specifications` are satisfied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specifications` is `null` Example:

    var specs = new List<Specification<Product>> { new ActiveSpec(), new InStockSpec() };
    var composite = Spec.All(specs);
  • methodAll<T>
    public static Specification<T> All<T>(params Specification<T>[] specifications)

    Composes all specifications using logical AND.

    specifications: params Specification<T>[]
    The specifications to compose with AND.

    Retorna: A specification that is satisfied only when all of `specifications` are satisfied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specifications` is `null` Example:

    var spec = Spec.All(new ActiveSpec(), new PremiumSpec(), new HasCreditSpec());
    // Equivalent to: new ActiveSpec().And(new PremiumSpec()).And(new HasCreditSpec())
  • methodAny<T>
    public static Specification<T> Any<T>(IEnumerable<Specification<T>> specifications)

    Composes a sequence of specifications using logical OR.

    specifications: IEnumerable<Specification<T>>
    The specifications sequence to compose with OR.

    Retorna: A specification that is satisfied when any of `specifications` is satisfied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specifications` is `null` Example:

    var specs = new List<Specification<Product>> { new PremiumSpec(), new VipSpec() };
    var composite = Spec.Any(specs);
  • methodAny<T>
    public static Specification<T> Any<T>(params Specification<T>[] specifications)

    Composes all specifications using logical OR.

    specifications: params Specification<T>[]
    The specifications to compose with OR.

    Retorna: A specification that is satisfied when any of `specifications` is satisfied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specifications` is `null` Example:

    var spec = Spec.Any(new PremiumSpec(), new VipSpec(), new StaffSpec());
    // Equivalent to: new PremiumSpec().Or(new VipSpec()).Or(new StaffSpec())
  • methodBetween<T, TProperty>
    public static Specification<T> Between<T, TProperty>(Expression<Func<T, TProperty?>> propertySelector, TProperty lower, TProperty upper) where TProperty : struct, IComparable<TProperty>

    Creates a specification that determines whether a nullable property value is inclusively between the lower and upper bounds.

    propertySelector: Expression<Func<T, TProperty?>>
    The property selector expression returning a nullable value.
    lower: TProperty
    The inclusive lower bound.
    upper: TProperty
    The inclusive upper bound.

    Retorna: A specification checking the range.

    Type parameters: T: The entity type.; TProperty: The underlying property type. Exceptions: ArgumentNullException: `propertySelector` is `null`; ArgumentException: `lower` is greater than `upper`

  • methodBetween<T, TProperty>
    public static Specification<T> Between<T, TProperty>(Expression<Func<T, TProperty>> propertySelector, TProperty lower, TProperty upper) where TProperty : IComparable<TProperty>

    Creates a specification that determines whether a property value is inclusively between the lower and upper bounds.

    propertySelector: Expression<Func<T, TProperty>>
    The property selector expression.
    lower: TProperty
    The inclusive lower bound.
    upper: TProperty
    The inclusive upper bound.

    Retorna: A specification checking the range.

    Type parameters: T: The entity type.; TProperty: The property type. Exceptions: ArgumentNullException: `propertySelector` is `null`; ArgumentException: `lower` is greater than `upper`

  • methodFalse<T>
    public static Specification<T> False<T>()

    Creates a specification that is never satisfied (contradiction).

    Retorna: A specification that always returns `false`.

    Type parameters: T: The entity type.

  • methodFor<T>
    public static Specification<T> For<T>(Expression<Func<T, bool>> predicate)

    Creates a specification from the specified predicate expression.

    predicate: Expression<Func<T, bool>>
    The predicate expression defining the rule.

    Retorna: A specification backed by the given predicate.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `predicate` is `null` Example:

    var activeSpec = Spec.For<Customer>(c => c.IsActive);
    var result = activeSpec.IsSatisfiedBy(customer);
  • methodFullText<T>
    public static Specification<T> FullText<T>(Expression<Func<T, string?>> propertySelector, string searchPhrase)

    Creates a specification that performs a case-insensitive full-text search match against a string property.

    propertySelector: Expression<Func<T, string?>>
    The property selector expression.
    searchPhrase: string
    The search phrase or keywords. The comparison is case-insensitive (uses `StringComparison.OrdinalIgnoreCase` internally).

    Retorna: A specification checking the full-text search match.

    This is the preferred entry point and delegates to `MatchesFullText<T>(Expression<Func<T, string?>>, string)`. Both methods are semantically identical; prefer `FullText` in new code for consistency with the cookbook. The comparison is case-insensitive (uses `StringComparison.OrdinalIgnoreCase` internally). Type parameters: T: The entity type. Exceptions: ArgumentNullException: `propertySelector` or `searchPhrase` is `null`

  • methodInRange<T, TProperty>
    public static Specification<T> InRange<T, TProperty>(Expression<Func<T, TProperty>> propertySelector, TProperty lower, TProperty upper) where TProperty : IComparable<TProperty>

    Creates a specification that determines whether a property value is inclusively between the lower and upper bounds.

    propertySelector: Expression<Func<T, TProperty>>
    The property selector expression.
    lower: TProperty
    The inclusive lower bound.
    upper: TProperty
    The inclusive upper bound.

    Retorna: A specification checking the range.

    Type parameters: T: The entity type.; TProperty: The property type. Exceptions: ArgumentNullException: `propertySelector` is `null`

  • methodMatchesFullText<T>
    public static Specification<T> MatchesFullText<T>(Expression<Func<T, string?>> propertySelector, string searchPhrase)

    Creates a specification that performs a case-insensitive full-text search match against a string property.

    propertySelector: Expression<Func<T, string?>>
    The property selector expression.
    searchPhrase: string
    The search phrase. The comparison is case-insensitive (uses `StringComparison.OrdinalIgnoreCase` internally).

    Retorna: A specification matching full text.

    This is the underlying implementation; prefer `FullText<T>(Expression<Func<T, string?>>, string)` in new code for API consistency. Both are functionally identical. Type parameters: T: The entity type. Exceptions: ArgumentNullException: `propertySelector` or `searchPhrase` is `null`

  • methodSearch<T>
    public static Specification<T> Search<T>(string searchPhrase, params Expression<Func<T, string?>>[] propertySelectors)

    Creates a specification that searches for a phrase across one or more string properties using logical OR.

    searchPhrase: string
    The text to search for.
    propertySelectors: params Expression<Func<T, string?>>[]
    The string property selectors to search within.

    Retorna: A specification checking if any of the specified properties contain `searchPhrase`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `searchPhrase`, `propertySelectors`, or any element of `propertySelectors` is `null`; ArgumentException: `propertySelectors` is empty Example: `var searchSpec = Spec.Search<Customer>("Acme", c => c.Name, c => c.Description);`

  • methodTrue<T>
    public static Specification<T> True<T>()

    Creates a specification that is always satisfied (tautology).

    Retorna: A specification that always returns `true`.

    Type parameters: T: The entity type.

class

Specification

Ensamblado: EricksonLopez.Specification
public static class Specification

Provides non-generic companion methods and static helpers for `Specification<T>` in accordance with .NET Framework Design Guidelines (CA1000 remediation).

Miembros (7)

  • methodAll<T>
    public static Specification<T> All<T>(params Specification<T>[] specifications)

    Composes all specifications using logical AND.

    specifications: params Specification<T>[]
    The specifications to compose with AND.

    Retorna: A specification that is satisfied only when all of `specifications` are satisfied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specifications` is `null`

  • methodBitwiseAnd<T>
    public static Specification<T> BitwiseAnd<T>(Specification<T> left, Specification<T> right)

    Combines two specifications using logical AND as a named alternate for operator &.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (`left` AND `right`).

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodBitwiseOr<T>
    public static Specification<T> BitwiseOr<T>(Specification<T> left, Specification<T> right)

    Combines two specifications using logical OR as a named alternate for operator |.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (`left` OR `right`).

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodFalse<T>
    public static Specification<T> False<T>()

    Creates a specification that is never satisfied (contradiction).

    Retorna: A specification that always returns `false`.

    Type parameters: T: The entity type.

  • methodFor<T>
    public static Specification<T> For<T>(Expression<Func<T, bool>> predicate)

    Creates a specification from the specified predicate expression. Non-generic companion factory alias to `Spec.For<T>(Expression<Func<T, bool>>)`.

    predicate: Expression<Func<T, bool>>
    The predicate expression defining the rule.

    Retorna: A specification backed by the given predicate.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `predicate` is `null`

  • methodLogicalNot<T>
    public static Specification<T> LogicalNot<T>(Specification<T> specification)

    Negates the specified specification as a named alternate for operator !.

    specification: Specification<T>
    The specification to negate.

    Retorna: A new negated specification representing (NOT `specification`).

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `specification` is `null`

  • methodTrue<T>
    public static Specification<T> True<T>()

    Creates a specification that is always satisfied (tautology).

    Retorna: A specification that always returns `true`.

    Type parameters: T: The entity type.

class

Specification<T>

Ensamblado: EricksonLopez.Specification
public abstract class Specification<T> : IExpressionSpecification<T>
Implementa: IExpressionSpecification<T>

Encapsulates a domain specification as an expression tree that can be evaluated in memory and translated by query providers.

Notas:

Guarantees thread safety. The underlying expression tree is lazily built and cached upon first access. Type parameters: T: The entity or value object type this specification evaluates.

Miembros (18)

  • methodAnd
    public Specification<T> And(Specification<T> other)

    Composes this specification with another using logical AND.

    other: Specification<T>
    The specification to combine with.

    Retorna: A new composite specification.

    Exceptions: ArgumentNullException: `other` is `null`

  • methodBitwiseAnd
    public static Specification<T> BitwiseAnd(Specification<T> left, Specification<T> right)

    Combines two specifications using logical AND as a named alternative to `operator &`.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (`left` AND `right`).

    Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodBitwiseOr
    public static Specification<T> BitwiseOr(Specification<T> left, Specification<T> right)

    Combines two specifications using logical OR as a named alternative to `operator |`.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (`left` OR `right`).

    Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodIsSatisfiedBy
    public bool IsSatisfiedBy(T candidate)

    Inherits documentation from base type or interface.

    candidate: T

    Exceptions: ArgumentNullException: `candidate` is `null`

  • methodLogicalNot
    public static Specification<T> LogicalNot(Specification<T> specification)

    Negates the specified specification as a named alternative to `operator !`.

    specification: Specification<T>
    The specification to negate.

    Retorna: A new negated specification representing (NOT `specification`).

    Exceptions: ArgumentNullException: `specification` is `null`

  • methodNot
    public virtual Specification<T> Not()

    Creates a new specification that represents the logical negation of this specification.

    Retorna: A new specification that is satisfied when this specification is not.

  • methodOr
    public Specification<T> Or(Specification<T> other)

    Composes this specification with another using logical OR.

    other: Specification<T>
    The specification to combine with.

    Retorna: A new composite specification.

    Exceptions: ArgumentNullException: `other` is `null`

  • methodToCompiledPredicate
    public Func<T, bool> ToCompiledPredicate()

    Compiles or retrieves the cached delegate for this specification expression.

    Retorna: A compiled predicate delegate.

    Results are cached globally by expression structural equality.

  • methodToDebugString
    public string ToDebugString()

    Returns a human-readable string representation of this specification's expression.

    Retorna: A string representation of the specification expression.

    The default implementation delegates to `ExpressionDebugFormatterRegistry`.

  • methodToExpression
    public Expression<Func<T, bool>> ToExpression()

    Converts this specification to a LINQ expression tree.

    Retorna: An expression tree representing the specification predicate.

  • methodToQuerySpec
    public QuerySpec<T> ToQuerySpec()

    Converts this specification to an equivalent `QuerySpec<T>`.

    Retorna: A new query specification constrained by this specification predicate.

  • methodToQuerySpec
    public QuerySpec<T> ToQuerySpec(QuerySpec<T> querySpec)

    Applies this specification predicate to the specified query specification.

    querySpec: QuerySpec<T>
    The query specification to apply this predicate to.

    Retorna: A new query specification containing the existing query settings and this predicate.

    Exceptions: ArgumentNullException: `querySpec` is `null`

  • methodimplicit operator QuerySpec<T>
    public static implicit operator QuerySpec<T>(Specification<T> specification)

    Converts a `Specification<T>` to a `QuerySpec<T>`.

    specification: Specification<T>
    The specification to convert.

    Retorna: A new query specification constrained by the specification predicate.

    Exceptions: ArgumentNullException: `specification` is `null`

  • methodoperator !
    public static Specification<T> operator !(Specification<T> specification)

    Negates the specified specification.

    specification: Specification<T>
    The specification to negate.

    Retorna: A new negated specification representing (NOT specification).

    Exceptions: ArgumentNullException: `specification` is `null`

  • methodoperator &
    public static Specification<T> operator &(Specification<T> left, Specification<T> right)

    Combines two specifications using logical AND.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (left AND right).

    Exceptions: ArgumentNullException: `left` or `right` is `null`

  • methodoperator false
    public static bool operator false(Specification<T> specification)

    Determines whether the specification evaluates to false for short-circuit evaluation in logical AND expressions.

    specification: Specification<T>
    The specification to evaluate.

    Retorna: Always `false` to ensure both operands are evaluated.

  • methodoperator true
    public static bool operator true(Specification<T> specification)

    Determines whether the specification evaluates to true for short-circuit evaluation in logical OR expressions.

    specification: Specification<T>
    The specification to evaluate.

    Retorna: Always `false` to ensure both operands are evaluated.

  • methodoperator |
    public static Specification<T> operator |(Specification<T> left, Specification<T> right)

    Combines two specifications using logical OR.

    left: Specification<T>
    The left specification.
    right: Specification<T>
    The right specification.

    Retorna: A new composite specification representing (left OR right).

    Exceptions: ArgumentNullException: `left` or `right` is `null`

EricksonLopez.Specification.Analyzers#

14
class

ArdalisMigrationAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class ArdalisMigrationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects classes inheriting from Ardalis.Specification to facilitate automated migration to EricksonLopez.Specification.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

ArdalisMigrationCodeFixProvider

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class ArdalisMigrationCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides automated code fixes for SPEC011 migrating from Ardalis.Specification to EricksonLopez.Specification.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

AsyncInExpressionAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class AsyncInExpressionAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects async lambdas or await expressions inside `BuildExpression()` in Specification subclasses (SPEC009).

Notas:

Expression trees cannot represent async/await operations. Placing them inside `BuildExpression()` causes IQueryable providers to throw at runtime.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

DomainSpecificationLayerAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class DomainSpecificationLayerAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects domain `Specification<T>` subclasses declared in Infrastructure namespaces (SPEC006).

Notas:

Domain specifications should live in the Domain layer. This analyzer flags any class inheriting from `Specification<T>` whose containing namespace contains tokens typically associated with the Infrastructure layer (e.g., `Infrastructure`, `Persistence`, `Data`, `Repository`, `EntityFramework`, `EfCore`). This rule is off by default (`isEnabledByDefault: false`) and can be enabled via `.editorconfig` when strict Clean Architecture enforcement is desired.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

ExpressionInvokeAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class ExpressionInvokeAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects `Expression.Invoke` calls inside `BuildExpression()` in Specification subclasses (SPEC003).

Notas:

`Expression.Invoke` creates `InvocationExpression` nodes that most LINQ providers (EF Core, SQL translators) cannot process. Use `ExpressionComposer.And/Or` instead, which rewrites parameter references via `ParameterReplacer`.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

InfrastructureInSpecAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class InfrastructureInSpecAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects infrastructure services (IServiceProvider, DbContext, repositories, clients, etc.) injected into the constructor of a Specification subclass (SPEC008).

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

IsSatisfiedByInExpressionAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class IsSatisfiedByInExpressionAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects calls to `IsSatisfiedBy()` inside `BuildExpression()` in Specification subclasses (SPEC010).

Notas:

`IsSatisfiedBy()` evaluates expressions by running the interpreter, producing a closure — not an expression tree node. Calling it inside `BuildExpression()` creates an expression tree that cannot be translated to SQL and will throw at runtime when passed to IQueryable providers.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

OrderingWithoutPaginationAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class OrderingWithoutPaginationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects `QuerySpec<T>` chains that apply ordering without pagination (SPEC005).

Notas:

Sorting large datasets without a row limit can be expensive. This diagnostic fires when a `QuerySpec<T>` chain includes `OrderBy`/`OrderByDescending` but no corresponding `Take`, `Page`, or cursor-based pagination.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

PotentialClientSideEvaluationAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class PotentialClientSideEvaluationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects method calls inside `BuildExpression()` that are likely non-translatable by IQueryable providers such as EF Core (SPEC007).

Notas:

Only a subset of .NET methods can be translated to SQL by LINQ providers. Method calls that have no known translation will typically cause client-side evaluation or runtime exceptions. This analyzer warns when a non-standard (non-BCL allowlisted) method is invoked inside a specification's `BuildExpression()` body. Known safe methods include: `string.Contains`, `string.StartsWith`, `string.EndsWith`, `string.IsNullOrEmpty`, `string.IsNullOrWhiteSpace`, `EF.Functions.*`, comparison operators, and member access.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

SpecificationDiagnosticDescriptors

Ensamblado: EricksonLopez.Specification.Analyzers
public static class SpecificationDiagnosticDescriptors

Provides centralized diagnostic descriptors for all specification analyzers.

Miembros (11)

  • fieldAsyncLambdaInExpression
    public static readonly DiagnosticDescriptor AsyncLambdaInExpression

    Gets the diagnostic descriptor for SPEC009: Async lambda or await expression inside BuildExpression.

  • fieldDomainSpecificationOutsideDomain
    public static readonly DiagnosticDescriptor DomainSpecificationOutsideDomain

    Gets the diagnostic descriptor for SPEC006: Domain specification defined outside Domain layer.

  • fieldExpressionInvokeDetected
    public static readonly DiagnosticDescriptor ExpressionInvokeDetected

    Gets the diagnostic descriptor for SPEC003: Expression.Invoke detected in specification expression.

  • fieldInfrastructureServiceInSpecification
    public static readonly DiagnosticDescriptor InfrastructureServiceInSpecification

    Gets the diagnostic descriptor for SPEC008: Infrastructure service injected into domain specification constructor.

  • fieldIsSatisfiedByInsideBuildExpression
    public static readonly DiagnosticDescriptor IsSatisfiedByInsideBuildExpression

    Gets the diagnostic descriptor for SPEC010: IsSatisfiedBy called inside BuildExpression.

  • fieldLegacyArdalisSpecificationDetected
    public static readonly DiagnosticDescriptor LegacyArdalisSpecificationDetected

    Gets the diagnostic descriptor for SPEC011: Legacy Ardalis.Specification usage detected.

  • fieldMutableStateInSpecification
    public static readonly DiagnosticDescriptor MutableStateInSpecification

    Gets the diagnostic descriptor for SPEC002: Mutable state in specification.

  • fieldOrderingWithoutPagination
    public static readonly DiagnosticDescriptor OrderingWithoutPagination

    Gets the diagnostic descriptor for SPEC005: QuerySpec has ordering but no pagination.

  • fieldPotentialClientSideEvaluation
    public static readonly DiagnosticDescriptor PotentialClientSideEvaluation

    Gets the diagnostic descriptor for SPEC007: Expression contains non-translatable method call.

  • fieldSpecificationShouldBeSealedOrAbstract
    public static readonly DiagnosticDescriptor SpecificationShouldBeSealedOrAbstract

    Gets the diagnostic descriptor for SPEC001: Specification class should be sealed or abstract.

  • fieldUnboundedQuery
    public static readonly DiagnosticDescriptor UnboundedQuery

    Gets the diagnostic descriptor for SPEC004: QuerySpec has no Take limit — potential unbounded query.

class

SpecificationMutableStateAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class SpecificationMutableStateAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects mutable fields and properties in Specification subclasses (SPEC002).

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

SpecificationSealedAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class SpecificationSealedAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects when a concrete class inheriting from Specification<T> is neither sealed nor abstract.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

SpecificationSealedCodeFixProvider

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class SpecificationSealedCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides a code fix for SPEC001: seals concrete specification classes.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

UnboundedQueryAnalyzer

Ensamblado: EricksonLopez.Specification.Analyzers
public sealed class UnboundedQueryAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects `QuerySpec<T>` chains that define no `Take` or `Page` limit (SPEC004).

Notas:

Queries without row limits may return large result sets and cause performance issues. This diagnostic fires when a `QuerySpec<T>` is produced without any call to `.Take()` or `.Page()` in the same fluent chain.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

EricksonLopez.Specification.Dapper#

1
class

QuerySpecDapperExtensions

Ensamblado: EricksonLopez.Specification.Dapper
public static class QuerySpecDapperExtensions

Provides extension methods for executing `QuerySpec<T>` against an `IDbConnection` using Dapper and a configured SQL dialect.

Notas:

Usage requires a configured `ISqlDialect` (e.g., `PostgreSqlDialect.Default`) and a `QuerySpecTranslator<T>` for the entity type. All queries are fully parameterized. No SQL injection is possible through the specification API.

Miembros (4)

  • methodAnyAsync<T>
    public static async Task<bool> AnyAsync<T>(this IDbConnection connection, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an EXISTS query based on the specification's filters.

    connection: this IDbConnection
    The database connection.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    transaction: IDbTransaction?
    An optional transaction to participate in.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation. The task result is `true` if at least one entity matches the specification; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `connection`, `spec`, `translator`, or `dialect` is `null`

  • methodCountAsync<T>
    public static async Task<int> CountAsync<T>(this IDbConnection connection, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a COUNT query based on the specification's filters.

    connection: this IDbConnection
    The database connection.
    spec: QuerySpec<T>
    The query specification (ordering and pagination are ignored for count).
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    transaction: IDbTransaction?
    An optional transaction to participate in.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation. The task result contains the count of entities matching the specification's filters.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `connection`, `spec`, `translator`, or `dialect` is `null`

  • methodQueryAsync<T>
    public static async Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection connection, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the specification as a SQL query and returns all matching results.

    connection: this IDbConnection
    The database connection.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    transaction: IDbTransaction?
    An optional transaction to participate in.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation. The task result contains all entities matching the specification.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `connection`, `spec`, `translator`, or `dialect` is `null`

  • methodQueryFirstOrDefaultAsync<T>
    public static async Task<T?> QueryFirstOrDefaultAsync<T>(this IDbConnection connection, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the specification and returns the first matching result, or default.

    connection: this IDbConnection
    The database connection.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    transaction: IDbTransaction?
    An optional transaction to participate in.
    commandTimeout: int?
    An optional commandTimeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation. The task result contains the first matching entity, or `null` if no entity matches.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `connection`, `spec`, `translator`, or `dialect` is `null`

EricksonLopez.Specification.DapperExtensions#

1
class

SpecificationDapperExtensions

Ensamblado: EricksonLopez.Specification.DapperExtensions
public static class SpecificationDapperExtensions

Provides extension methods for evaluating `QuerySpec<T>` against `IUnitOfWork` within the Dapper extensions ecosystem.

Miembros (3)

  • methodCountAsync<T>
    public static async Task<int> CountAsync<T>(this IUnitOfWork unitOfWork, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Counts the number of entities matching the specification using the `IUnitOfWork`.

    unitOfWork: this IUnitOfWork
    The active unit of work.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the count of matching entities.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `unitOfWork`, `spec`, `translator`, or `dialect` is `null`; InvalidOperationException: The UnitOfWork transaction has no associated connection

  • methodQueryAsync<T>
    public static async Task<IEnumerable<T>> QueryAsync<T>(this IUnitOfWork unitOfWork, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the specification against the connection and transaction managed by the `IUnitOfWork` and returns all matching entities.

    unitOfWork: this IUnitOfWork
    The active unit of work.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation with matching entities.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `unitOfWork`, `spec`, `translator`, or `dialect` is `null`; InvalidOperationException: The UnitOfWork transaction has no associated connection

  • methodQueryFirstOrDefaultAsync<T>
    public static async Task<T?> QueryFirstOrDefaultAsync<T>(this IUnitOfWork unitOfWork, QuerySpec<T> spec, QuerySpecTranslator<T> translator, ISqlDialect dialect, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the specification against the `IUnitOfWork` and returns the first matching entity or default.

    unitOfWork: this IUnitOfWork
    The active unit of work.
    spec: QuerySpec<T>
    The query specification.
    translator: QuerySpecTranslator<T>
    The translator for mapping the specification to SQL.
    dialect: ISqlDialect
    The SQL dialect to use for rendering.
    commandTimeout: int?
    An optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A task representing the asynchronous operation with the entity or default.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `unitOfWork`, `spec`, `translator`, or `dialect` is `null`; InvalidOperationException: The UnitOfWork transaction has no associated connection

EricksonLopez.Specification.Diagnostics#

1
class

SpecificationDiagnostics

Ensamblado: EricksonLopez.Specification
public static class SpecificationDiagnostics

Provides OpenTelemetry activity sources and meters for the specification library.

Miembros (12)

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the diagnostic activity source for distributed tracing.

  • fieldActivitySourceName
    public const string ActivitySourceName

    Gets the OpenTelemetry activity source name for specification operations.

  • fieldExpressionCacheHits
    public static readonly Counter<long> ExpressionCacheHits

    Gets the counter tracking the number of expression compilation cache hits.

  • fieldExpressionCacheMisses
    public static readonly Counter<long> ExpressionCacheMisses

    Gets the counter tracking the number of expression compilation cache misses.

  • fieldMeter
    public static readonly Meter Meter

    Gets the OpenTelemetry meter instance.

  • fieldMeterName
    public const string MeterName

    Gets the OpenTelemetry meter name for specifications.

  • fieldSpecificationsCompiled
    public static readonly Counter<long> SpecificationsCompiled

    Gets the counter tracking total specifications compiled.

  • fieldSpecificationsComposed
    public static readonly Counter<long> SpecificationsComposed

    Gets the counter tracking total specifications composed.

  • fieldSpecificationsCreated
    public static readonly Counter<long> SpecificationsCreated

    Gets the counter tracking total specifications created.

  • fieldSpecificationsEvaluated
    public static readonly Counter<long> SpecificationsEvaluated

    Gets the counter tracking total specifications evaluated.

  • fieldSqlTranslationDuration
    public static readonly Histogram<double> SqlTranslationDuration

    Gets the histogram tracking the duration of SQL translation operations in milliseconds.

  • fieldSqlTranslations
    public static readonly Counter<long> SqlTranslations

    Gets the counter tracking the number of successful SQL translation operations.

EricksonLopez.Specification.EntityFrameworkCore#

5
class

EfReadRepository<TEntity>

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public class EfReadRepository<TEntity> : EfReadRepository<DbContext, TEntity> where TEntity : class
Hereda de: EfReadRepository<DbContext, TEntity>

Provides an Entity Framework Core implementation of `IReadRepository<T>` for the default `DbContext`.

Notas:

Type parameters: TEntity: The entity type.

Miembros (1)

  • constructorEfReadRepository
    public EfReadRepository(DbContext dbContext, ISpecificationEvaluator? evaluator = null)

    Initializes a new instance of the `EfReadRepository<TEntity>` class.

    dbContext: DbContext
    The database context.
    evaluator: ISpecificationEvaluator?
    The optional specification evaluator.

    Exceptions: ArgumentNullException: `dbContext` is `null`

class

EfReadRepository<TDbContext, TEntity>

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public class EfReadRepository<TDbContext, TEntity> : IReadRepository<TEntity> where TDbContext : DbContext where TEntity : class
Implementa: IReadRepository<TEntity>

Provides an Entity Framework Core implementation of `IReadRepository<T>` for a specific `TDbContext`.

Notas:

Type parameters: TDbContext: The concrete database context type.; TEntity: The entity type.

Miembros (8)

  • constructorEfReadRepository
    public EfReadRepository(TDbContext dbContext, ISpecificationEvaluator? evaluator = null)

    Initializes a new instance of the `EfReadRepository<TDbContext, TEntity>` class.

    dbContext: TDbContext
    The database context.
    evaluator: ISpecificationEvaluator?
    The optional specification evaluator.

    Exceptions: ArgumentNullException: `dbContext` is `null`

  • methodAnyAsync
    public async Task<bool> AnyAsync(QuerySpec<TEntity> specification, CancellationToken cancellationToken = default)

    Determines whether any entity matches the specification.

    specification: QuerySpec<TEntity>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains `true` if at least one entity matches; otherwise, `false`.

  • methodCountAsync
    public async Task<int> CountAsync(QuerySpec<TEntity> specification, CancellationToken cancellationToken = default)

    Calculates the number of entities matching the specification.

    specification: QuerySpec<TEntity>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the count of matching entities.

  • methodFirstOrDefaultAsync
    public async Task<TEntity?> FirstOrDefaultAsync(QuerySpec<TEntity> specification, CancellationToken cancellationToken = default)

    Retrieves the first entity matching the specification, or `null` if none found.

    specification: QuerySpec<TEntity>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the first matching entity, or `null` if not found.

  • methodGetByIdAsync<TId>
    public virtual async Task<TEntity?> GetByIdAsync<TId>(TId id, CancellationToken cancellationToken = default) where TId : notnull

    Retrieves an entity by its identifier.

    id: TId
    The entity identifier.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the matching entity, or `null` if not found.

    The default interface implementation throws `NotSupportedException`. Implementors must override this method to provide actual entity lookup by identifier. Type parameters: TId: The identifier type.

  • methodListAsync
    public async Task<IReadOnlyList<TEntity>> ListAsync(QuerySpec<TEntity> specification, CancellationToken cancellationToken = default)

    Retrieves all entities matching the specification.

    specification: QuerySpec<TEntity>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a read-only list of matching entities.

  • methodListAsync<TResult>
    public async Task<IReadOnlyList<TResult>> ListAsync<TResult>(QuerySpec<TEntity, TResult> specification, CancellationToken cancellationToken = default)

    Retrieves projected results for entities matching the specification.

    specification: QuerySpec<TEntity, TResult>
    The query specification with projection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a read-only list of projected results.

    Type parameters: TResult: The projected result type.

  • methodSingleOrDefaultAsync
    public async Task<TEntity?> SingleOrDefaultAsync(QuerySpec<TEntity> specification, CancellationToken cancellationToken = default)

    Retrieves the single entity matching the specification, or `null` if none found.

    specification: QuerySpec<TEntity>
    The query specification to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the single matching entity, or `null` if not found.

    Exceptions: InvalidOperationException: More than one entity matches the specification

class

EfSpecificationEvaluator

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public class EfSpecificationEvaluator : ISpecificationEvaluator
Implementa: ISpecificationEvaluator

Evaluates and applies `QuerySpec<T>` and `QuerySpec<T, TResult>` descriptors to EF Core `IQueryable<T>` query pipelines.

Miembros (3)

  • methodGetQuery<T, TResult>
    public static IQueryable<TResult> GetQuery<T, TResult>(IQueryable<T> source, QuerySpec<T, TResult> specification)

    Applies the projected specification to the specified source queryable.

    source: IQueryable<T>
    The source queryable.
    specification: QuerySpec<T, TResult>
    The projected query specification.

    Retorna: The modified queryable projected to `TResult`.

    Type parameters: T: The entity type.; TResult: The projected result type.

  • methodGetQuery<T>
    public static IQueryable<T> GetQuery<T>(IQueryable<T> source, QuerySpec<T> specification)

    Applies the specification to the specified source queryable.

    source: IQueryable<T>
    The source queryable.
    specification: QuerySpec<T>
    The query specification.

    Retorna: The modified queryable ready for execution.

    Type parameters: T: The entity type.

  • propertyDefault
    public static EfSpecificationEvaluator Default { get; }

    Gets the default singleton instance of `EfSpecificationEvaluator`.

interface

ISpecificationEvaluator

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public interface ISpecificationEvaluator

Defines a contract for evaluating and applying specifications to EF Core queryable pipelines.

Miembros (2)

  • methodGetQuery<T, TResult>
    IQueryable<TResult> GetQuery<T, TResult>(IQueryable<T> source, QuerySpec<T, TResult> specification)

    Applies a projected query specification to the specified source queryable.

    source: IQueryable<T>
    The source queryable.
    specification: QuerySpec<T, TResult>
    The projected query specification.

    Retorna: The modified queryable projected to `TResult`.

    Type parameters: T: The entity type.; TResult: The projected result type.

  • methodGetQuery<T>
    IQueryable<T> GetQuery<T>(IQueryable<T> source, QuerySpec<T> specification)

    Applies a query specification to the specified source queryable.

    source: IQueryable<T>
    The source queryable.
    specification: QuerySpec<T>
    The query specification.

    Retorna: The modified queryable ready for execution.

    Type parameters: T: The entity type.

class

QuerySpecEfCoreExtensions

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public static class QuerySpecEfCoreExtensions

Provides EF Core-specific extension methods for query specification configuration and execution.

Miembros (2)

  • methodApply<T, TResult>
    public static IQueryable<TResult> Apply<T, TResult>(this IQueryable<T> source, QuerySpec<T, TResult> specification, bool asSplitQuery = false, bool ignoreAutoIncludes = false) where T : class

    Applies the projected specification to the source `IQueryable<T>` with optional split query and auto-includes configuration.

    source: this IQueryable<T>
    The source queryable.
    specification: QuerySpec<T, TResult>
    The projected query specification.
    asSplitQuery: bool
    If `true`, configures the query to use multiple SQL queries (`AsSplitQuery`).
    ignoreAutoIncludes: bool
    If `true`, configures the query to ignore auto-included navigations (`IgnoreAutoIncludes`).

    Retorna: The configured queryable.

    Type parameters: T: The entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodApply<T>
    public static IQueryable<T> Apply<T>(this IQueryable<T> source, QuerySpec<T> specification, bool asSplitQuery = false, bool ignoreAutoIncludes = false) where T : class

    Applies the specification to the source `IQueryable<T>` with optional split query and auto-includes configuration.

    source: this IQueryable<T>
    The source queryable.
    specification: QuerySpec<T>
    The query specification.
    asSplitQuery: bool
    If `true`, configures the query to use multiple SQL queries (`AsSplitQuery`).
    ignoreAutoIncludes: bool
    If `true`, configures the query to ignore auto-included navigations (`IgnoreAutoIncludes`).

    Retorna: The configured queryable.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

EricksonLopez.Specification.EntityFrameworkCore.Infrastructure#

1
class

SpecificationDbContextOptionsExtension

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public sealed class SpecificationDbContextOptionsExtension : IDbContextOptionsExtension
Implementa: IDbContextOptionsExtension

EF Core options extension registering Specification relational query translator plugins.

Miembros (3)

  • methodApplyServices
    public void ApplyServices(IServiceCollection services)

    Inherits documentation from base type or interface.

    services: IServiceCollection
  • methodValidate
    public void Validate(IDbContextOptions options)

    Inherits documentation from base type or interface.

    options: IDbContextOptions
  • propertyInfo
    public DbContextOptionsExtensionInfo Info { get; }

    Inherits documentation from base type or interface.

EricksonLopez.Specification.EntityFrameworkCore.Query#

2
class

FullTextMethodCallTranslator

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public sealed class FullTextMethodCallTranslator : IMethodCallTranslator
Implementa: IMethodCallTranslator

Translates `FullTextExtensions.MatchesFullText` method calls to SQL LIKE expressions in EF Core.

Miembros (2)

  • constructorFullTextMethodCallTranslator
    public FullTextMethodCallTranslator(ISqlExpressionFactory sqlExpressionFactory)

    Initializes a new instance of the `FullTextMethodCallTranslator` class.

    sqlExpressionFactory: ISqlExpressionFactory
    The SQL expression factory.

    Exceptions: ArgumentNullException: `sqlExpressionFactory` is `null`

  • methodTranslate
    public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)

    Inherits documentation from base type or interface.

    instance: SqlExpression?
    method: MethodInfo
    arguments: IReadOnlyList<SqlExpression>
    logger: IDiagnosticsLogger<DbLoggerCategory.Query>
class

FullTextMethodCallTranslatorPlugin

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public sealed class FullTextMethodCallTranslatorPlugin : IMethodCallTranslatorPlugin
Implementa: IMethodCallTranslatorPlugin

EF Core method call translator plugin registering full-text search translation.

Miembros (2)

  • constructorFullTextMethodCallTranslatorPlugin
    public FullTextMethodCallTranslatorPlugin(ISqlExpressionFactory sqlExpressionFactory)

    Initializes a new instance of the `FullTextMethodCallTranslatorPlugin` class.

    sqlExpressionFactory: ISqlExpressionFactory
    The SQL expression factory.

    Exceptions: ArgumentNullException: `sqlExpressionFactory` is `null`

  • propertyTranslators
    public IEnumerable<IMethodCallTranslator> Translators { get; }

    Inherits documentation from base type or interface.

EricksonLopez.Specification.Generators#

1
class

SpecificationGenerator

Ensamblado: EricksonLopez.Specification.Generators
public sealed class SpecificationGenerator : IIncrementalGenerator
Implementa: IIncrementalGenerator

Generates strongly-typed ordering helpers and AOT-safe specification metadata for types annotated with `[Spec]`.

Notas:

This generator processes classes annotated with the `[Spec]` attribute and emits strongly-typed ordering extensions to avoid string-based ordering APIs. Example:

[Spec]
public sealed partial class CustomerSpecifications
{
    // Generator produces:
    //   public static Expression<Func<Customer, object?>> OrderByName
    //   public static Expression<Func<Customer, object?>> OrderByCreditLimit
    //   ... etc
}

Miembros (1)

  • methodInitialize
    public void Initialize(IncrementalGeneratorInitializationContext context)

    Inherits documentation from base type or interface.

    context: IncrementalGeneratorInitializationContext

EricksonLopez.Specification.Linq#

1
class

QuerySpecLinqExtensions

Ensamblado: EricksonLopez.Specification.Linq
public static class QuerySpecLinqExtensions

Provides extension methods for applying `QuerySpec<T>` to `IQueryable<T>` sources.

Notas:

These extensions apply the specification's criteria, ordering, pagination, and other modifiers to an `IQueryable<T>` source. They work with any IQueryable provider including EF Core, LINQ to Objects, and in-memory collections. The extension methods do NOT call `ToList()`, `ToArray()`, or any materializing method — the returned value is always a composed `IQueryable<T>` ready for further composition or execution.

Miembros (12)

  • methodAll<T>
    public static bool All<T>(this IEnumerable<T> source, ISpecification<T> specification)

    Determines whether all elements of an in-memory sequence satisfy a domain specification.

    source: this IEnumerable<T>
    An `IEnumerable<T>` to evaluate.
    specification: ISpecification<T>
    A domain specification to test each element for a condition.

    Retorna: `true` if every element passes the test in the specified specification, or if the sequence is empty; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodAll<T>
    public static bool All<T>(this IQueryable<T> source, IExpressionSpecification<T> specification)

    Determines whether all elements in the source satisfy the specified specification predicate.

    source: this IQueryable<T>
    The source queryable.
    specification: IExpressionSpecification<T>
    The specification whose predicate to test.

    Retorna: `true` if every element satisfies the predicate, or if the source is empty; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodAny<T>
    public static bool Any<T>(this IEnumerable<T> source, ISpecification<T> specification)

    Determines whether any element of an in-memory sequence satisfies a domain specification.

    source: this IEnumerable<T>
    An `IEnumerable<T>` to evaluate.
    specification: ISpecification<T>
    A domain specification to test each element for a condition.

    Retorna: `true` if any elements in the source sequence satisfy the condition; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodAny<T>
    public static bool Any<T>(this IQueryable<T> source, IExpressionSpecification<T> specification)

    Determines whether any element in the source satisfies the specified specification predicate.

    source: this IQueryable<T>
    The source queryable.
    specification: IExpressionSpecification<T>
    The specification whose predicate to test.

    Retorna: `true` if any element satisfies the predicate; otherwise, `false`.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodApply<T, TResult>
    public static IQueryable<TResult> Apply<T, TResult>(this IQueryable<T> source, QuerySpec<T, TResult> spec)

    Applies a projected `QuerySpec<T, TResult>` to an `IQueryable<T>` source.

    source: this IQueryable<T>
    The source queryable.
    spec: QuerySpec<T, TResult>
    The projected specification to apply.

    Retorna: A queryable of projected results.

    Type parameters: T: The source entity type.; TResult: The projected result type. Exceptions: ArgumentNullException: `source` or `spec` is `null`; InvalidOperationException: `spec` does not define a projection selector

  • methodApply<T>
    public static IQueryable<T> Apply<T>(this IQueryable<T> source, QuerySpec<T> spec)

    Applies a `QuerySpec<T>` to an `IQueryable<T>` source.

    source: this IQueryable<T>
    The source queryable.
    spec: QuerySpec<T>
    The specification to apply.

    Retorna: A queryable with all specification criteria, ordering, and pagination applied.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `spec` is `null`

  • methodCount<T>
    public static int Count<T>(this IEnumerable<T> source, ISpecification<T> specification)

    Returns the number of elements in an in-memory sequence that satisfy a domain specification.

    source: this IEnumerable<T>
    An `IEnumerable<T>` to evaluate.
    specification: ISpecification<T>
    A domain specification to test each element for a condition.

    Retorna: A number that represents how many elements in the sequence satisfy the condition in the specification.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodCount<T>
    public static int Count<T>(this IQueryable<T> source, IExpressionSpecification<T> specification)

    Calculates the number of elements in the source that satisfy the specified specification predicate.

    source: this IQueryable<T>
    The source queryable.
    specification: IExpressionSpecification<T>
    The specification whose predicate to test.

    Retorna: The number of elements satisfying the specification.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodFirstOrDefault<T>
    public static T? FirstOrDefault<T>(this IEnumerable<T> source, ISpecification<T> specification)

    Returns the first element of an in-memory sequence that satisfies a domain specification, or a default value if no such element is found.

    source: this IEnumerable<T>
    An `IEnumerable<T>` to return an element from.
    specification: ISpecification<T>
    A domain specification to test each element for a condition.

    Retorna: `default`(`T`) if `source` is empty or if no element passes the test; otherwise, the first matching element.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodFirstOrDefault<T>
    public static T? FirstOrDefault<T>(this IQueryable<T> source, IExpressionSpecification<T> specification)

    Returns the first element of a sequence that satisfies an expression specification, or a default value if no such element is found.

    source: this IQueryable<T>
    The source queryable.
    specification: IExpressionSpecification<T>
    The specification whose predicate to test.

    Retorna: `default`(`T`) if `source` is empty or if no element passes the test; otherwise, the first matching element.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodWhere<T>
    public static IEnumerable<T> Where<T>(this IEnumerable<T> source, ISpecification<T> specification)

    Filters an in-memory sequence of values based on a domain specification.

    source: this IEnumerable<T>
    An `IEnumerable<T>` to filter.
    specification: ISpecification<T>
    A domain specification to test each element for a condition.

    Retorna: An `IEnumerable<T>` that contains elements from the input sequence that satisfy the specification.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

  • methodWhere<T>
    public static IQueryable<T> Where<T>(this IQueryable<T> source, IExpressionSpecification<T> specification)

    Filters a sequence of values based on a predicate defined by an expression specification.

    source: this IQueryable<T>
    The source queryable.
    specification: IExpressionSpecification<T>
    The specification whose predicate to test.

    Retorna: An `IQueryable<T>` that contains elements from the input sequence that satisfy the specification.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `source` or `specification` is `null`

EricksonLopez.Specification.MariaDb#

1
class

MariaDbDialect

Ensamblado: EricksonLopez.Specification.MariaDb
public sealed class MariaDbDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as MariaDB-compatible SQL.

Notas:

Key MariaDB-specific behaviors: - Identifiers are quoted with backticks: ``table_name`` - Parameters use the named format: `@paramName` - `LIMIT n OFFSET m` for pagination - `IN (@p_0, @p_1, ...)` for collection membership — parameters are expanded inline - `LIKE` string matching with `%` wildcards - `MATCH ... AGAINST(... IN NATURAL LANGUAGE MODE)` for full-text search

Miembros (3)

  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Inherits documentation from base type or interface.

    identifier: string

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Inherits documentation from base type or interface.

  • fieldDefault
    public static readonly MariaDbDialect Default

    Gets the shared singleton instance with default configuration.

EricksonLopez.Specification.MongoDB#

3
class

MongoReadRepository<TDocument>

Ensamblado: EricksonLopez.Specification.MongoDB
public class MongoReadRepository<TDocument>

Provides a specification-driven asynchronous read repository implementation for MongoDB collections.

Notas:

Type parameters: TDocument: The document type.

Miembros (4)

  • constructorMongoReadRepository
    public MongoReadRepository(IMongoCollection<TDocument> collection)

    Initializes a new instance of the `MongoReadRepository<TDocument>` class.

    collection: IMongoCollection<TDocument>
    The Mongo collection instance.

    Exceptions: ArgumentNullException: `collection` is `null`

  • methodCountAsync
    public virtual Task<long> CountAsync(QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Calculates the number of documents matching the specified query specification.

    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: The count of matching documents.

    Exceptions: ArgumentNullException: `specification` is `null`

  • methodFirstOrDefaultAsync
    public virtual Task<TDocument?> FirstOrDefaultAsync(QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Retrieves the first document matching the specified query specification, or default if none match.

    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: The matching document, or `null` if not found.

    Exceptions: ArgumentNullException: `specification` is `null`

  • methodListAsync
    public virtual Task<List<TDocument>> ListAsync(QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Retrieves all documents matching the specified query specification.

    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A list of matching documents.

    Exceptions: ArgumentNullException: `specification` is `null`

class

MongoSpecificationEvaluator

Ensamblado: EricksonLopez.Specification.MongoDB
public static class MongoSpecificationEvaluator

Evaluates and compiles `QuerySpec<T>` descriptors into MongoDB filter and sort definitions.

Miembros (4)

  • methodApplySpecification<TDocument>
    public static IFindFluent<TDocument, TDocument> ApplySpecification<TDocument>(this IFindFluent<TDocument, TDocument> findFluent, QuerySpec<TDocument> specification)

    Applies specification criteria, sorting, and pagination to an `IFindFluent<TDocument, TDocument>` query.

    findFluent: this IFindFluent<TDocument, TDocument>
    The source fluent find instance.
    specification: QuerySpec<TDocument>
    The query specification.

    Retorna: The configured fluent find query.

    Type parameters: TDocument: The MongoDB document type. Exceptions: ArgumentNullException: `findFluent` or `specification` is `null`

  • methodFind<TDocument>
    public static IFindFluent<TDocument, TDocument> Find<TDocument>(this IMongoCollection<TDocument> collection, QuerySpec<TDocument> specification)

    Executes a find query on the specified collection using the criteria, ordering, and pagination from a `QuerySpec<T>`.

    collection: this IMongoCollection<TDocument>
    The source MongoDB collection.
    specification: QuerySpec<TDocument>
    The query specification.

    Retorna: A configured fluent find instance.

    Type parameters: TDocument: The MongoDB document type. Exceptions: ArgumentNullException: `collection` or `specification` is `null`

  • methodGetFilter<TDocument>
    public static FilterDefinition<TDocument> GetFilter<TDocument>(QuerySpec<TDocument> specification)

    Builds a MongoDB `FilterDefinition<TDocument>` from the specified specification criteria.

    specification: QuerySpec<TDocument>
    The query specification.

    Retorna: A combined `FilterDefinition<TDocument>`.

    Type parameters: TDocument: The MongoDB document type. Exceptions: ArgumentNullException: `specification` is `null`

  • methodGetSort<TDocument>
    public static SortDefinition<TDocument>? GetSort<TDocument>(QuerySpec<TDocument> specification)

    Builds a MongoDB `SortDefinition<TDocument>` from the specified specification ordering expressions.

    specification: QuerySpec<TDocument>
    The query specification.

    Retorna: A combined `SortDefinition<TDocument>`, or `null` if no order was specified.

    Type parameters: TDocument: The MongoDB document type. Exceptions: ArgumentNullException: `specification` is `null`

class

MongoSpecificationExtensions

Ensamblado: EricksonLopez.Specification.MongoDB
public static class MongoSpecificationExtensions

Provides extension methods for executing specifications against MongoDB collections.

Miembros (3)

  • methodCountDocumentsAsync<TDocument>
    public static async Task<long> CountDocumentsAsync<TDocument>(this IMongoCollection<TDocument> collection, QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Counts documents matching the specified specification asynchronously.

    collection: this IMongoCollection<TDocument>
    The Mongo collection.
    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: The total count of matching documents.

    Type parameters: TDocument: The document type. Exceptions: ArgumentNullException: `collection` or `specification` is `null`

  • methodFindAsync<TDocument>
    public static async Task<List<TDocument>> FindAsync<TDocument>(this IMongoCollection<TDocument> collection, QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Finds documents matching the specified specification asynchronously.

    collection: this IMongoCollection<TDocument>
    The Mongo collection.
    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A list of matching documents.

    Type parameters: TDocument: The document type. Exceptions: ArgumentNullException: `collection` or `specification` is `null`

  • methodFirstOrDefaultAsync<TDocument>
    public static async Task<TDocument?> FirstOrDefaultAsync<TDocument>(this IMongoCollection<TDocument> collection, QuerySpec<TDocument> specification, CancellationToken cancellationToken = default)

    Finds the first document matching the specified specification, or returns default if none match.

    collection: this IMongoCollection<TDocument>
    The Mongo collection.
    specification: QuerySpec<TDocument>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: The matching document, or `null` if not found.

    Type parameters: TDocument: The document type. Exceptions: ArgumentNullException: `collection` or `specification` is `null`

EricksonLopez.Specification.MsSql#

1
class

MsSqlDialect

Ensamblado: EricksonLopez.Specification.MsSql
public sealed class MsSqlDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as SQL Server (T-SQL)-compatible SQL.

Notas:

Key SQL Server-specific behaviors: - Identifiers quoted with square brackets: `[table_name]` - Parameters use named format: `@paramName` - Pagination uses OFFSET ... ROWS FETCH NEXT ... ROWS ONLY (SQL Server 2012+) - TOP N used when only Take is specified without Skip - IN predicate expands collections into individual named parameters

Miembros (3)

  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Inherits documentation from base type or interface.

    identifier: string

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Inherits documentation from base type or interface.

  • fieldDefault
    public static readonly MsSqlDialect Default

    Gets the shared singleton instance with default configuration.

EricksonLopez.Specification.MySql#

1
class

MySqlDialect

Ensamblado: EricksonLopez.Specification.MySql
public sealed class MySqlDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as MySQL- and MariaDB-compatible SQL.

Notas:

Key MySQL/MariaDB-specific behaviors: - Identifiers are quoted with backticks: ``table_name`` - Parameters use the named format: `@paramName` - `LIMIT n OFFSET m` for pagination - `IN (@p_0, @p_1, ...)` for collection membership — parameters are expanded inline - `LIKE` string matching with `%` wildcards

Miembros (3)

  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Inherits documentation from base type or interface.

    identifier: string

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Inherits documentation from base type or interface.

  • fieldDefault
    public static readonly MySqlDialect Default

    Gets the shared singleton instance with default configuration.

EricksonLopez.Specification.Oracle#

1
class

OracleDialect

Ensamblado: EricksonLopez.Specification.Oracle
public sealed class OracleDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as Oracle Database-compatible SQL.

Notas:

Key Oracle-specific behaviors: - Identifiers quoted with double quotes: `"table_name"` - Parameters use colon prefix: `:paramName` - Table aliases in FROM clause do not use `AS` keyword (Oracle syntax: `FROM "table" "alias"`) - Pagination uses standard Oracle 12c+ `OFFSET ... ROWS FETCH NEXT ... ROWS ONLY` - IN predicate expands collections into individual positional/named parameters (`:param_0, :param_1`) - Full-text search uses Oracle Text syntax: `CONTAINS("col", :param) > 0`

Miembros (4)

  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Inherits documentation from base type or interface.

    identifier: string

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Inherits documentation from base type or interface.

  • propertyParameterPrefix
    public override string ParameterPrefix { get; }

    Inherits documentation from base type or interface.

  • fieldDefault
    public static readonly OracleDialect Default

    Gets the shared singleton instance with default configuration.

EricksonLopez.Specification.PostgreSql#

1
class

PostgreSqlDialect

Ensamblado: EricksonLopez.Specification.PostgreSql
public sealed class PostgreSqlDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as PostgreSQL-compatible SQL.

Notas:

Key PostgreSQL-specific behaviors: - Identifiers are quoted with double-quotes: `"table_name"` - Parameters use the named format: `@paramName` - LIMIT and OFFSET for pagination - ILIKE for case-insensitive string matching (opt-in)

Miembros (4)

  • constructorPostgreSqlDialect
    public PostgreSqlDialect(bool useCaseInsensitiveLike = false)

    Initializes a new instance of the `PostgreSqlDialect` class.

    useCaseInsensitiveLike: bool
    When `true`, LIKE is rendered as ILIKE for case-insensitive matching. Default is `false`.
  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Inherits documentation from base type or interface.

    identifier: string

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Inherits documentation from base type or interface.

  • fieldDefault
    public static readonly PostgreSqlDialect Default

    Gets the shared singleton instance with default configuration.

EricksonLopez.Specification.Result#

1
class

ReadRepositoryResultExtensions

Ensamblado: EricksonLopez.Specification.Result
public static class ReadRepositoryResultExtensions

Provides extension methods for `IReadRepository<T>` to execute specifications returning a result.

Miembros (4)

  • methodFirstOrDefaultResultAsync<T>
    public static async Task<Result<T>> FirstOrDefaultResultAsync<T>(this IReadRepository<T> repository, QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves the first entity matching the specification, returning a result. Maps null results to a standard NotFound error.

    repository: this IReadRepository<T>
    The read repository.
    specification: QuerySpec<T>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A result containing the matching entity, or a failure result if not found or an error occurs.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `repository` is `null`

  • methodGetByIdResultAsync<T, TId>
    public static async Task<Result<T>> GetByIdResultAsync<T, TId>(this IReadRepository<T> repository, TId id, CancellationToken cancellationToken = default) where TId : notnull

    Retrieves an entity by its identifier, returning a result. Maps null results to a standard NotFound error.

    repository: this IReadRepository<T>
    The read repository.
    id: TId
    The entity identifier.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A result containing the entity with the specified identifier, or a failure result if not found or an error occurs.

    Type parameters: T: The entity type.; TId: The type of the identifier. Exceptions: ArgumentNullException: `repository` is `null`

  • methodListResultAsync<T>
    public static async Task<Result<IReadOnlyList<T>>> ListResultAsync<T>(this IReadRepository<T> repository, QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves all entities matching the specification, returning a result list.

    repository: this IReadRepository<T>
    The read repository.
    specification: QuerySpec<T>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A result containing all matching entities, or a failure result if an error occurs.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `repository` is `null`

  • methodSingleOrDefaultResultAsync<T>
    public static async Task<Result<T>> SingleOrDefaultResultAsync<T>(this IReadRepository<T> repository, QuerySpec<T> specification, CancellationToken cancellationToken = default)

    Retrieves the single entity matching the specification, returning a result. Maps null results to NotFound, and multiple matches to a Conflict error.

    repository: this IReadRepository<T>
    The read repository.
    specification: QuerySpec<T>
    The query specification.
    cancellationToken: CancellationToken
    A token to cancel the operation.

    Retorna: A result containing the matching entity, or a failure result if not found, multiple entities match, or an error occurs.

    Type parameters: T: The entity type. Exceptions: ArgumentNullException: `repository` is `null`

EricksonLopez.Specification.Sql#

22
record

AndPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record AndPredicateNode(SqlPredicateNode Left, SqlPredicateNode Right) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a logical AND composition of two SQL predicates.

Miembros (3)

  • constructorAndPredicateNode
    public AndPredicateNode(SqlPredicateNode Left, SqlPredicateNode Right)

    Initializes a new instance of AndPredicateNode.

    Left: SqlPredicateNode
    The left operand predicate.
    Right: SqlPredicateNode
    The right operand predicate.
  • propertyLeft
    public SqlPredicateNode Left { get; init; }

    The left operand predicate.

  • propertyRight
    public SqlPredicateNode Right { get; init; }

    The right operand predicate.

record

BetweenPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record BetweenPredicateNode(string ColumnName, string LowerParameterName, string UpperParameterName, bool Negated) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a BETWEEN range predicate on a column.

Miembros (5)

  • constructorBetweenPredicateNode
    public BetweenPredicateNode(string ColumnName, string LowerParameterName, string UpperParameterName, bool Negated = false)

    Initializes a new instance of BetweenPredicateNode.

    ColumnName: string
    The SQL column name.
    LowerParameterName: string
    The lower bound parameter name.
    UpperParameterName: string
    The upper bound parameter name.
    Negated: bool
    A value indicating whether the BETWEEN condition is negated.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyLowerParameterName
    public string LowerParameterName { get; init; }

    The lower bound parameter name.

  • propertyNegated
    public bool Negated { get; init; }

    A value indicating whether the BETWEEN condition is negated.

  • propertyUpperParameterName
    public string UpperParameterName { get; init; }

    The upper bound parameter name.

record

BinaryPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record BinaryPredicateNode(string ColumnName, SqlBinaryOperator Operator, string ParameterName) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a binary comparison predicate comparing a column against a parameterized value.

Miembros (4)

  • constructorBinaryPredicateNode
    public BinaryPredicateNode(string ColumnName, SqlBinaryOperator Operator, string ParameterName)

    Initializes a new instance of BinaryPredicateNode.

    ColumnName: string
    The SQL column name.
    Operator: SqlBinaryOperator
    The binary comparison operator.
    ParameterName: string
    The SQL parameter name.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyOperator
    public SqlBinaryOperator Operator { get; init; }

    The binary comparison operator.

  • propertyParameterName
    public string ParameterName { get; init; }

    The SQL parameter name.

record

FullTextPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record FullTextPredicateNode(string ColumnName, string ParameterName, string Language) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a full-text search predicate on a column.

Miembros (4)

  • constructorFullTextPredicateNode
    public FullTextPredicateNode(string ColumnName, string ParameterName, string Language = "")

    Initializes a new instance of FullTextPredicateNode.

    ColumnName: string
    The SQL column name.
    ParameterName: string
    The search phrase parameter name.
    Language: string
    The text search configuration language.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyLanguage
    public string Language { get; init; }

    The text search configuration language.

  • propertyParameterName
    public string ParameterName { get; init; }

    The search phrase parameter name.

interface

IColumnNameResolver

Ensamblado: EricksonLopez.Specification.Sql
public interface IColumnNameResolver

Defines a contract for resolving C# property names to SQL column names.

Miembros (1)

  • methodResolve
    string Resolve(string propertyName)

    Resolves a C# property name to a SQL column name.

    propertyName: string
    The C# property name (e.g., "IsActive").

    Retorna: The SQL column name (e.g., "is_active").

interface

ISqlDialect

Ensamblado: EricksonLopez.Specification.Sql
public interface ISqlDialect

Defines the contract for SQL dialect implementations that render query models into dialect-specific SQL.

Miembros (4)

  • methodQuoteIdentifier
    string QuoteIdentifier(string identifier)

    Quotes an identifier according to dialect rules.

    identifier: string
    The identifier to quote.

    Retorna: The quoted identifier string.

  • methodRender
    SqlQuery Render(QueryModel model)

    Renders the specified `QueryModel` into dialect-specific SQL.

    model: QueryModel
    The query model to render.

    Retorna: A rendered SQL query with parameters.

  • propertyDialectName
    string DialectName { get; }

    Gets the human-readable name of this dialect.

  • propertyParameterPrefix
    string ParameterPrefix { get; }

    Gets the parameter prefix used by this dialect.

record

InPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record InPredicateNode(string ColumnName, string ParameterName, bool Negated) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents an IN predicate comparing a column against a collection of values.

Miembros (4)

  • constructorInPredicateNode
    public InPredicateNode(string ColumnName, string ParameterName, bool Negated = false)

    Initializes a new instance of InPredicateNode.

    ColumnName: string
    The SQL column name.
    ParameterName: string
    The SQL parameter name.
    Negated: bool
    A value indicating whether the IN condition is negated.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyNegated
    public bool Negated { get; init; }

    A value indicating whether the IN condition is negated.

  • propertyParameterName
    public string ParameterName { get; init; }

    The SQL parameter name.

record

NotPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record NotPredicateNode(SqlPredicateNode Inner) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a logical NOT negation of a SQL predicate.

Miembros (2)

  • constructorNotPredicateNode
    public NotPredicateNode(SqlPredicateNode Inner)

    Initializes a new instance of NotPredicateNode.

    Inner: SqlPredicateNode
    The inner predicate to negate.
  • propertyInner
    public SqlPredicateNode Inner { get; init; }

    The inner predicate to negate.

record

OrPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record OrPredicateNode(SqlPredicateNode Left, SqlPredicateNode Right) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a logical OR composition of two SQL predicates.

Miembros (3)

  • constructorOrPredicateNode
    public OrPredicateNode(SqlPredicateNode Left, SqlPredicateNode Right)

    Initializes a new instance of OrPredicateNode.

    Left: SqlPredicateNode
    The left operand predicate.
    Right: SqlPredicateNode
    The right operand predicate.
  • propertyLeft
    public SqlPredicateNode Left { get; init; }

    The left operand predicate.

  • propertyRight
    public SqlPredicateNode Right { get; init; }

    The right operand predicate.

record

QueryModel

Ensamblado: EricksonLopez.Specification.Sql
public sealed record QueryModel

Represents a provider-agnostic intermediate representation of a SQL query. Produced from a `QuerySpec<T>` and consumed by an `ISqlDialect` to generate dialect-specific SQL.

Miembros (11)

  • propertyFilters
    public ImmutableArray<SqlPredicateNode> Filters { get; init; }

    Gets the filter predicates in the SQL AST form.

  • propertyIsDistinct
    public bool IsDistinct { get; init; }

    Gets a value indicating whether to apply DISTINCT.

  • propertyOrders
    public ImmutableArray<SqlOrderNode> Orders { get; init; }

    Gets the ordering clauses.

  • propertyParameters
    public ImmutableArray<SqlParameter> Parameters { get; init; }

    Gets the collected SQL parameters for this query.

  • propertyProjections
    public ImmutableArray<string> Projections { get; init; }

    Gets the column projections. Empty means SELECT *.

  • propertyQueryType
    public SqlQueryType QueryType { get; init; }

    Gets the type of query (Select, Count, Exists).

  • propertySkip
    public int? Skip { get; init; }

    Gets the number of rows to skip (OFFSET).

  • propertyTableAlias
    public string? TableAlias { get; init; }

    Gets the optional table alias to use in the query.

  • propertyTableName
    public required string TableName { get; init; }

    Gets the name of the table or view being queried.

  • propertyTag
    public string? Tag { get; init; }

    Gets the optional diagnostic query tag/comment.

  • propertyTake
    public int? Take { get; init; }

    Gets the maximum number of rows to return (LIMIT / TOP).

class

QueryPlanCache

Ensamblado: EricksonLopez.Specification.Sql
public static class QueryPlanCache

Provides a bounded LRU (Least Recently Used) cache for generated `QueryModel` plans, keyed by expression structural equality and table name.

Notas:

Prevents unbounded memory consumption by enforcing a strict capacity limit (default: 512 plans). When capacity is exceeded, the least recently used query plans are evicted in O(1) time.

Miembros (5)

  • methodClear
    public static void Clear()

    Clears all entries from the query plan cache.

  • methodSetPlan
    public static void SetPlan(Expression criteria, string tableName, QueryModel plan)

    Stores or updates a `QueryModel` in the LRU cache.

    criteria: Expression
    The expression criteria.
    tableName: string
    The target database table name.
    plan: QueryModel
    The translated query model to cache.

    Exceptions: ArgumentNullException: `criteria`, `tableName`, or `plan` is `null`

  • methodTryGetPlan
    public static bool TryGetPlan(Expression criteria, string tableName, out QueryModel plan)

    Attempts to retrieve a cached `QueryModel` for the specified criteria and table.

    criteria: Expression
    The expression criteria to look up.
    tableName: string
    The target database table name.
    plan: out QueryModel
    The resolved query plan if found; otherwise `null`.

    Retorna: `true` if a cached plan was found; otherwise, `false`.

    Exceptions: ArgumentNullException: `criteria` or `tableName` is `null`

  • propertyCapacity
    public static int Capacity { get; internal set; }

    Gets or sets the maximum number of query plans retained in the cache. Default is 512.

  • propertyCount
    public static int Count { get; }

    Gets the current number of query plans held in the cache.

class

QuerySpecTranslator<T>

Ensamblado: EricksonLopez.Specification.Sql
public sealed class QuerySpecTranslator<T>

Translates a `QuerySpec<T>` into a provider-agnostic `QueryModel`.

Notas:

The translator walks the expression trees in the `QuerySpec<T>` and maps them to provider-agnostic `SqlPredicateNode` instances. The mapping from C# property names to SQL column names uses snake_case by default. Provide a custom `IColumnNameResolver` to override naming conventions. Type parameters: T: The entity type.

Miembros (2)

  • constructorQuerySpecTranslator
    public QuerySpecTranslator(string tableName, IColumnNameResolver? columnNameResolver = null)

    Initializes a new instance of the `QuerySpecTranslator<T>` class.

    tableName: string
    The SQL table name for type `T`.
    columnNameResolver: IColumnNameResolver?
    The resolver for mapping property names to column names.

    Exceptions: ArgumentException: `tableName` is `null` or whitespace

  • methodTranslate
    public QueryModel Translate(QuerySpec<T> spec)

    Translates the specified `QuerySpec<T>` to a `QueryModel`.

    spec: QuerySpec<T>
    The specification to translate.

    Retorna: A `QueryModel` representing the query.

    Exceptions: ArgumentNullException: `spec` is `null`

record

RangePredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record RangePredicateNode(string ColumnName, string LowerParameterName, string UpperParameterName, bool Inclusive) : SqlPredicateNode
Hereda de: SqlPredicateNode

Represents a range inclusion predicate on a column.

Miembros (5)

  • constructorRangePredicateNode
    public RangePredicateNode(string ColumnName, string LowerParameterName, string UpperParameterName, bool Inclusive = true)

    Initializes a new instance of RangePredicateNode.

    ColumnName: string
    The SQL column name.
    LowerParameterName: string
    The lower bound parameter name.
    UpperParameterName: string
    The upper bound parameter name.
    Inclusive: bool
    A value indicating whether bounds are inclusive.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyInclusive
    public bool Inclusive { get; init; }

    A value indicating whether bounds are inclusive.

  • propertyLowerParameterName
    public string LowerParameterName { get; init; }

    The lower bound parameter name.

  • propertyUpperParameterName
    public string UpperParameterName { get; init; }

    The upper bound parameter name.

class

SnakeCaseColumnNameResolver

Ensamblado: EricksonLopez.Specification.Sql
public sealed class SnakeCaseColumnNameResolver : IColumnNameResolver
Implementa: IColumnNameResolver

Converts PascalCase or camelCase property names to snake_case SQL column names.

Notas:

Example: `IsActive` → `is_active` `CreditLimit` → `credit_limit` `CustomerId` → `customer_id`

Miembros (2)

  • methodResolve
    public string Resolve(string propertyName)

    Resolves a C# property name to a SQL column name.

    propertyName: string
    The C# property name (e.g., "IsActive").

    Retorna: The SQL column name (e.g., "is_active").

    Exceptions: ArgumentException: `propertyName` is `null` or whitespace

  • fieldDefault
    public static readonly SnakeCaseColumnNameResolver Default

    Gets the shared singleton instance.

enum

SqlBinaryOperator

Ensamblado: EricksonLopez.Specification.Sql
public enum SqlBinaryOperator

Specifies the binary comparison operators used in SQL predicates.

Miembros (12)

  • fieldEqual
    Equal

    Compares two values for equality (`=`).

  • fieldGreaterThan
    GreaterThan

    Tests that the left operand is strictly greater than the right (`>`).

  • fieldGreaterThanOrEqual
    GreaterThanOrEqual

    Tests that the left operand is greater than or equal to the right (`>=`).

  • fieldIsNotNull
    IsNotNull

    Tests that the column value is not SQL NULL (IS NOT NULL).

  • fieldIsNull
    IsNull

    Tests that the column value is SQL NULL (IS NULL).

  • fieldLessThan
    LessThan

    Tests that the left operand is strictly less than the right (`<`).

  • fieldLessThanOrEqual
    LessThanOrEqual

    Tests that the left operand is less than or equal to the right (`<=`).

  • fieldLike
    Like

    LIKE with `%arg%` wrapping (string.Contains).

  • fieldLikeEndsWith
    LikeEndsWith

    LIKE with `%arg` suffix pattern (string.EndsWith).

  • fieldLikeStartsWith
    LikeStartsWith

    LIKE with `arg%` prefix pattern (string.StartsWith).

  • fieldNotEqual
    NotEqual

    Compares two values for inequality (`<>`).

  • fieldNotLike
    NotLike

    Negated pattern match — column does NOT match the pattern (NOT LIKE).

class

SqlDialectBase

Ensamblado: EricksonLopez.Specification.Sql
public abstract class SqlDialectBase : ISqlDialect
Implementa: ISqlDialect

Provides a base implementation of `ISqlDialect` containing standard AST traversal, parameter management, predicate rendering, and extensible SQL clause composition.

Miembros (4)

  • methodQuoteIdentifier
    public abstract string QuoteIdentifier(string identifier)

    Quotes an identifier according to dialect rules.

    identifier: string
    The identifier to quote.

    Retorna: The quoted identifier string.

  • methodRender
    public virtual SqlQuery Render(QueryModel model)

    Renders the specified `QueryModel` into dialect-specific SQL.

    model: QueryModel
    The query model to render.

    Retorna: A rendered SQL query with parameters.

    Exceptions: ArgumentNullException: `model` is `null`

  • propertyDialectName
    public abstract string DialectName { get; }

    Gets the human-readable name of this dialect.

  • propertyParameterPrefix
    public virtual string ParameterPrefix { get; }

    Gets the parameter prefix used by this dialect.

record

SqlOrderNode

Ensamblado: EricksonLopez.Specification.Sql
public sealed record SqlOrderNode(string ColumnName, OrderDirection Direction)

Represents a column ordering instruction for a SQL ORDER BY clause.

Miembros (3)

  • constructorSqlOrderNode
    public SqlOrderNode(string ColumnName, OrderDirection Direction)

    Initializes a new instance of SqlOrderNode.

    ColumnName: string
    The SQL column name.
    Direction: OrderDirection
    The ordering direction.
  • propertyColumnName
    public string ColumnName { get; init; }

    The SQL column name.

  • propertyDirection
    public OrderDirection Direction { get; init; }

    The ordering direction.

record

SqlParameter

Ensamblado: EricksonLopez.Specification.Sql
public sealed record SqlParameter(string Name, object? Value)

Represents a SQL query parameter with its name and value.

Miembros (3)

  • constructorSqlParameter
    public SqlParameter(string Name, object? Value)

    Initializes a new instance of SqlParameter.

    Name: string
    The parameter name.
    Value: object?
    The parameter value.
  • propertyName
    public string Name { get; init; }

    The parameter name.

  • propertyValue
    public object? Value { get; init; }

    The parameter value.

record

SqlPredicateNode

Ensamblado: EricksonLopez.Specification.Sql
public abstract record SqlPredicateNode

Provides an abstract base record for all SQL predicate AST nodes.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

record

SqlQuery

Ensamblado: EricksonLopez.Specification.Sql
public sealed record SqlQuery

Represents the rendered output of a SQL translation, containing a parameterized SQL string and named parameters.

Notas:

All generated SQL is fully parameterized. Literal values are never interpolated directly into the SQL string to prevent SQL injection.

Miembros (3)

  • propertyParameters
    public required IReadOnlyDictionary<string, object?> Parameters { get; init; }

    Gets the parameters as a dictionary suitable for use with Dapper, Npgsql, or other drivers. Keys are parameter names (without the @ or $ prefix depending on dialect).

  • propertySql
    public required string Sql { get; init; }

    Gets the parameterized SQL string.

  • fieldEmpty
    public static readonly SqlQuery Empty

    Gets an empty SQL query.

enum

SqlQueryType

Ensamblado: EricksonLopez.Specification.Sql
public enum SqlQueryType

Specifies the type of SQL query to generate.

Miembros (3)

  • fieldCount
    Count

    Specifies a COUNT(*) query returning the row count.

  • fieldExists
    Exists

    Specifies an EXISTS query returning whether matching rows exist.

  • fieldSelect
    Select

    Specifies a standard SELECT query returning rows.

class

VerbatimColumnNameResolver

Ensamblado: EricksonLopez.Specification.Sql
public sealed class VerbatimColumnNameResolver : IColumnNameResolver
Implementa: IColumnNameResolver

Returns property names unchanged (verbatim mapping). Use when columns match property names exactly.

Miembros (2)

  • methodResolve
    public string Resolve(string propertyName)

    Resolves a C# property name to a SQL column name.

    propertyName: string
    The C# property name (e.g., "IsActive").

    Retorna: The SQL column name (e.g., "is_active").

    Exceptions: ArgumentException: `propertyName` is `null` or whitespace

  • fieldDefault
    public static readonly VerbatimColumnNameResolver Default

    Gets the shared singleton instance.

EricksonLopez.Specification.Sqlite#

1
class

SqliteDialect

Ensamblado: EricksonLopez.Specification.Sqlite
public sealed class SqliteDialect : SqlDialectBase
Hereda de: SqlDialectBase

Renders `QueryModel` instances as SQLite-compatible SQL.

Notas:

Key SQLite-specific behaviors: - Identifiers are quoted with double-quotes: `"table_name"` - Parameters use the named format: `@paramName` - `LIMIT n OFFSET m` for pagination - `IN (@p_0, @p_1, ...)` for collection membership — parameters are expanded inline - `LIKE` only — no ILIKE (SQLite LIKE is case-insensitive for ASCII by default) Primary use case: integration and unit testing without an external server. For production use cases, prefer `PostgreSqlDialect` or `MsSqlDialect`. Note on case-insensitive LIKE: SQLite's LIKE is case-insensitive for ASCII by default. Enable `PRAGMA case_sensitive_like = ON` at the connection level to opt into case-sensitive matching.

Miembros (3)

  • methodQuoteIdentifier
    public override string QuoteIdentifier(string identifier)

    Quotes an identifier according to dialect rules.

    identifier: string
    The identifier to quote.

    Retorna: The quoted identifier string.

    Exceptions: ArgumentException: `identifier` is `null` or whitespace

  • propertyDialectName
    public override string DialectName { get; }

    Gets the human-readable name of this dialect.

  • fieldDefault
    public static readonly SqliteDialect Default

    Gets the shared singleton instance with default configuration.

Microsoft.EntityFrameworkCore#

1
class

SpecificationDbContextOptionsExtensions

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public static class SpecificationDbContextOptionsExtensions

Provides extension methods to enable EricksonLopez.Specification services in EF Core.

Miembros (2)

  • methodUseSpecification
    public static DbContextOptionsBuilder UseSpecification(this DbContextOptionsBuilder optionsBuilder)

    Configures the `DbContext` to use EricksonLopez.Specification relational services, enabling SQL translation for `Spec.FullText` and `FullTextExtensions.MatchesFullText`.

    optionsBuilder: this DbContextOptionsBuilder
    The builder being used to configure the context.

    Retorna: The options builder so that further configuration can be chained.

    Exceptions: ArgumentNullException: `optionsBuilder` is `null`

  • methodUseSpecification<TContext>
    public static DbContextOptionsBuilder<TContext> UseSpecification<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder) where TContext : DbContext

    Configures the `DbContext` to use EricksonLopez.Specification relational services, enabling SQL translation for `Spec.FullText` and `FullTextExtensions.MatchesFullText`.

    optionsBuilder: this DbContextOptionsBuilder<TContext>
    The builder being used to configure the context.

    Retorna: The options builder so that further configuration can be chained.

    Type parameters: TContext: The context type being configured. Exceptions: ArgumentNullException: `optionsBuilder` is `null`

Microsoft.Extensions.DependencyInjection#

1
class

SpecificationEntityFrameworkServiceCollectionExtensions

Ensamblado: EricksonLopez.Specification.EntityFrameworkCore
public static class SpecificationEntityFrameworkServiceCollectionExtensions

Provides extension methods for registering EF Core specification services and repositories in an `IServiceCollection`.

Miembros (3)

  • methodAddEfReadRepository<TDbContext, TEntity>
    public static IServiceCollection AddEfReadRepository<TDbContext, TEntity>(this IServiceCollection services) where TDbContext : DbContext where TEntity : class

    Registers strongly-typed `IReadRepository<TEntity>` backed by `EfReadRepository<TDbContext, TEntity>`.

    services: this IServiceCollection
    The service collection.

    Retorna: The modified service collection.

    Type parameters: TDbContext: The concrete database context type.; TEntity: The entity type. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddSpecificationEntityFramework
    public static IServiceCollection AddSpecificationEntityFramework(this IServiceCollection services)

    Registers generic `IReadRepository<T>` mapped to `EfReadRepository<T>`.

    services: this IServiceCollection
    The service collection.

    Retorna: The modified service collection.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddSpecificationEntityFramework<TDbContext>
    public static IServiceCollection AddSpecificationEntityFramework<TDbContext>(this IServiceCollection services) where TDbContext : DbContext

    Registers generic `IReadRepository<T>` mapped to `EfReadRepository<T>`.

    services: this IServiceCollection
    The service collection.

    Retorna: The modified service collection.

    Type parameters: TDbContext: The concrete database context type. Exceptions: ArgumentNullException: `services` is `null`

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.