Table of Contents

Class OrderEntityBuilder<TEntity>

Namespace
FluentCommand.Query
Assembly
FluentCommand.dll

Provides a builder for constructing SQL ORDER BY clauses for a specific entity type with fluent, chainable methods.

public class OrderEntityBuilder<TEntity> : OrderBuilder<OrderEntityBuilder<TEntity>>, IStatementBuilder, IQueryBuilder where TEntity : class

Type Parameters

TEntity

The type of the entity.

Inheritance
OrderEntityBuilder<TEntity>
Implements
Inherited Members

Constructors

OrderEntityBuilder(IQueryGenerator, List<QueryParameter>)

Initializes a new instance of the OrderEntityBuilder<TEntity> class.

public OrderEntityBuilder(IQueryGenerator queryGenerator, List<QueryParameter> parameters)

Parameters

queryGenerator IQueryGenerator

The IQueryGenerator used to generate SQL expressions.

parameters List<QueryParameter>

The list of QueryParameter objects for the query.

Methods

OrderByIf<TValue>(Expression<Func<TEntity, TValue>>, string, SortDirections, Func<string, bool>)

Conditionally adds an ORDER BY clause with the specified entity property, sort direction, and table alias.

public OrderEntityBuilder<TEntity> OrderByIf<TValue>(Expression<Func<TEntity, TValue>> property, string tableAlias = null, SortDirections sortDirection = SortDirections.Ascending, Func<string, bool> condition = null)

Parameters

property Expression<Func<TEntity, TValue>>

An expression selecting the property to sort by.

tableAlias string

The alias of the table (optional).

sortDirection SortDirections

The sort direction (default is Ascending).

condition Func<string, bool>

A function that determines whether to add the ORDER BY clause, based on the property name. If null, the clause is always added.

Returns

OrderEntityBuilder<TEntity>

The same builder instance for method chaining.

Type Parameters

TValue

The type of the property value.

OrderBy<TValue>(Expression<Func<TEntity, TValue>>, SortDirections)

Adds an ORDER BY clause with the specified entity property and sort direction.

public OrderEntityBuilder<TEntity> OrderBy<TValue>(Expression<Func<TEntity, TValue>> property, SortDirections sortDirection = SortDirections.Ascending)

Parameters

property Expression<Func<TEntity, TValue>>

An expression selecting the property to sort by.

sortDirection SortDirections

The sort direction (default is Ascending).

Returns

OrderEntityBuilder<TEntity>

The same builder instance for method chaining.

Type Parameters

TValue

The type of the property value.

OrderBy<TValue>(Expression<Func<TEntity, TValue>>, string, SortDirections)

Adds an ORDER BY clause with the specified entity property, sort direction, and table alias.

public OrderEntityBuilder<TEntity> OrderBy<TValue>(Expression<Func<TEntity, TValue>> property, string tableAlias, SortDirections sortDirection = SortDirections.Ascending)

Parameters

property Expression<Func<TEntity, TValue>>

An expression selecting the property to sort by.

tableAlias string

The alias of the table (optional).

sortDirection SortDirections

The sort direction (default is Ascending).

Returns

OrderEntityBuilder<TEntity>

The same builder instance for method chaining.

Type Parameters

TValue

The type of the property value.