Search Results for

    Show / Hide Table of Contents
    View Source

    Class Query<T>

    Represents a query builder.

    Inheritance
    object
    Namespace: Umbraco.Cms.Infrastructure.Persistence.Querying
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class Query<T> : IQuery<T>
    Type Parameters
    Name Description
    T
    Remarks

    A query builder translates Linq queries into Sql queries.

    Constructors

    View Source

    Query(ISqlContext)

    Initializes a new instance of the Query<T> class using the specified SQL context.

    Declaration
    public Query(ISqlContext sqlContext)
    Parameters
    Type Name Description
    ISqlContext sqlContext

    The ISqlContext instance that provides SQL generation and mapping capabilities for the query.

    Methods

    View Source

    GetWhereClauses()

    Returns all translated where clauses and their associated SQL parameters.

    Declaration
    public IEnumerable<Tuple<string, object[]>> GetWhereClauses()
    Returns
    Type Description
    IEnumerable<Tuple<string, object[]>>

    An enumerable of tuples, each containing a where clause string and its associated SQL parameters.

    View Source

    Where(Expression<Func<T, bool>>?)

    Adds a WHERE clause to the query using the specified predicate expression.

    Declaration
    public virtual IQuery<T> Where(Expression<Func<T, bool>>? predicate)
    Parameters
    Type Name Description
    Expression<Func<T, bool>> predicate

    The predicate expression used to filter the query results. If null, no filtering is applied.

    Returns
    Type Description
    IQuery<T>

    An IQuery<T> representing the query with the applied WHERE clause.

    View Source

    WhereAny(IEnumerable<Expression<Func<T, bool>>>?)

    Adds a set of where clauses to the query, combined using the logical OR operator.

    Declaration
    public virtual IQuery<T> WhereAny(IEnumerable<Expression<Func<T, bool>>>? predicates)
    Parameters
    Type Name Description
    IEnumerable<Expression<Func<T, bool>>> predicates

    A collection of predicate expressions to combine with OR in the where clause. If null or empty, no clauses are added.

    Returns
    Type Description
    IQuery<T>

    The current IQuery<T> instance with the OR-ed where clauses applied.

    View Source

    WhereIn(Expression<Func<T, object>>?, IEnumerable?)

    Adds a where-in clause to the query for the specified field and values.

    Declaration
    public virtual IQuery<T> WhereIn(Expression<Func<T, object>>? fieldSelector, IEnumerable? values)
    Parameters
    Type Name Description
    Expression<Func<T, object>> fieldSelector

    An expression that selects the field to which the where-in clause will be applied.

    IEnumerable values

    A collection of values to match against the selected field.

    Returns
    Type Description
    IQuery<T>

    An IQuery<T> representing the query with the where-in clause applied.

    View Source

    WhereNotIn(Expression<Func<T, object>>?, IEnumerable?)

    Adds a WHERE NOT IN clause to the query for the specified field and values.

    Declaration
    public virtual IQuery<T> WhereNotIn(Expression<Func<T, object>>? fieldSelector, IEnumerable? values)
    Parameters
    Type Name Description
    Expression<Func<T, object>> fieldSelector

    An expression that selects the field to which the WHERE NOT IN clause will be applied.

    IEnumerable values

    A collection of values to exclude from the results for the specified field.

    Returns
    Type Description
    IQuery<T>

    The current IQuery<T> instance with the WHERE NOT IN clause applied.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX