Search Results for

    Show / Hide Table of Contents

    Class QueryHelper

    Inheritance
    object
    QueryHelper
    Namespace: LinqToDB.SqlQuery
    Assembly: linq2db.dll
    Syntax
    public static class QueryHelper

    Methods

    | Improve this Doc View Source

    CanBeEvaluated(IQueryElement, EvaluationContext)

    Declaration
    public static bool CanBeEvaluated(this IQueryElement expr, EvaluationContext context)
    Parameters
    Type Name Description
    IQueryElement expr
    EvaluationContext context
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    CanBeEvaluated(IQueryElement, bool)

    Declaration
    public static bool CanBeEvaluated(this IQueryElement expr, bool withParameters)
    Parameters
    Type Name Description
    IQueryElement expr
    bool withParameters
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    CanRemoveOrderBy(SelectQuery, SqlProviderFlags, QueryInformation)

    Detects when we can remove order

    Declaration
    public static bool CanRemoveOrderBy(SelectQuery selectQuery, SqlProviderFlags flags, QueryInformation information)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    SqlProviderFlags flags
    QueryInformation information
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    CollectDependencies(IQueryElement, IEnumerable<ISqlTableSource>, HashSet<ISqlExpression>, IEnumerable<IQueryElement>?)

    Declaration
    public static void CollectDependencies(IQueryElement root, IEnumerable<ISqlTableSource> sources, HashSet<ISqlExpression> found, IEnumerable<IQueryElement>? ignore = null)
    Parameters
    Type Name Description
    IQueryElement root
    IEnumerable<ISqlTableSource> sources
    HashSet<ISqlExpression> found
    IEnumerable<IQueryElement> ignore
    | Improve this Doc View Source

    CollectUniqueKeys(ISqlTableSource, bool, List<IList<ISqlExpression>>)

    Collects unique keys from different sources.

    Declaration
    public static void CollectUniqueKeys(ISqlTableSource tableSource, bool includeDistinct, List<IList<ISqlExpression>> knownKeys)
    Parameters
    Type Name Description
    ISqlTableSource tableSource
    bool includeDistinct

    Flag to include Distinct as unique key.

    List<IList<ISqlExpression>> knownKeys

    List with found keys.

    | Improve this Doc View Source

    CollectUniqueKeys(SqlTableSource, List<IList<ISqlExpression>>)

    Collects unique keys from different sources.

    Declaration
    public static void CollectUniqueKeys(SqlTableSource tableSource, List<IList<ISqlExpression>> knownKeys)
    Parameters
    Type Name Description
    SqlTableSource tableSource
    List<IList<ISqlExpression>> knownKeys

    List with found keys.

    | Improve this Doc View Source

    CollectUsedSources(IQueryElement, HashSet<ISqlTableSource>, IEnumerable<IQueryElement>?)

    Declaration
    public static void CollectUsedSources(IQueryElement root, HashSet<ISqlTableSource> found, IEnumerable<IQueryElement>? ignore = null)
    Parameters
    Type Name Description
    IQueryElement root
    HashSet<ISqlTableSource> found
    IEnumerable<IQueryElement> ignore
    | Improve this Doc View Source

    ConcatSearchCondition(SqlWhereClause, SqlSearchCondition)

    Declaration
    public static void ConcatSearchCondition(this SqlWhereClause where, SqlSearchCondition search)
    Parameters
    Type Name Description
    SqlWhereClause where
    SqlSearchCondition search
    | Improve this Doc View Source

    ContainsAggregationOrWindowFunction(IQueryElement)

    Declaration
    public static bool ContainsAggregationOrWindowFunction(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    ContainsAggregationOrWindowFunctionDeep(IQueryElement)

    Declaration
    public static bool ContainsAggregationOrWindowFunctionDeep(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    ContainsAggregationOrWindowFunctionOneLevel(IQueryElement)

    Declaration
    public static bool ContainsAggregationOrWindowFunctionOneLevel(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    ContainsElement(IQueryElement, IQueryElement)

    Declaration
    public static bool ContainsElement(IQueryElement testedRoot, IQueryElement element)
    Parameters
    Type Name Description
    IQueryElement testedRoot
    IQueryElement element
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    ConvertFormatToConcatenation(string, IList<ISqlExpression>)

    Declaration
    public static ISqlExpression ConvertFormatToConcatenation(string format, IList<ISqlExpression> parameters)
    Parameters
    Type Name Description
    string format
    IList<ISqlExpression> parameters
    Returns
    Type Description
    ISqlExpression
    | Improve this Doc View Source

    CorrectSearchConditionNesting(SelectQuery, SqlCondition, HashSet<ISqlTableSource>)

    Declaration
    public static SqlCondition CorrectSearchConditionNesting(SelectQuery sql, SqlCondition condition, HashSet<ISqlTableSource> forTableSources)
    Parameters
    Type Name Description
    SelectQuery sql
    SqlCondition condition
    HashSet<ISqlTableSource> forTableSources
    Returns
    Type Description
    SqlCondition
    | Improve this Doc View Source

    CountElements(ISqlExpression)

    Declaration
    public static IDictionary<QueryElementType, int> CountElements(ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    IDictionary<QueryElementType, int>
    | Improve this Doc View Source

    DependencyCount(IQueryElement, IQueryElement, HashSet<IQueryElement>?)

    Declaration
    public static int DependencyCount(IQueryElement testedRoot, IQueryElement onElement, HashSet<IQueryElement>? elementsToIgnore = null)
    Parameters
    Type Name Description
    IQueryElement testedRoot
    IQueryElement onElement
    HashSet<IQueryElement> elementsToIgnore
    Returns
    Type Description
    int
    | Improve this Doc View Source

    EnsureConjunction(SqlSearchCondition)

    Ensures that expression is not A OR B but (A OR B) Function makes all needed manipulations for that

    Declaration
    public static SqlSearchCondition EnsureConjunction(this SqlSearchCondition searchCondition)
    Parameters
    Type Name Description
    SqlSearchCondition searchCondition
    Returns
    Type Description
    SqlSearchCondition
    | Improve this Doc View Source

    EnsureConjunction(SqlWhereClause)

    Ensures that expression is not A OR B but (A OR B) Function makes all needed manipulations for that

    Declaration
    public static SqlWhereClause EnsureConjunction(this SqlWhereClause whereClause)
    Parameters
    Type Name Description
    SqlWhereClause whereClause
    Returns
    Type Description
    SqlWhereClause
    | Improve this Doc View Source

    EnumerateAccessibleSources(SelectQuery)

    Enumerates table sources recursively based on joins

    Declaration
    public static IEnumerable<ISqlTableSource> EnumerateAccessibleSources(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<ISqlTableSource>
    | Improve this Doc View Source

    EnumerateAccessibleSources(SqlTableSource)

    Declaration
    public static IEnumerable<ISqlTableSource> EnumerateAccessibleSources(SqlTableSource tableSource)
    Parameters
    Type Name Description
    SqlTableSource tableSource
    Returns
    Type Description
    IEnumerable<ISqlTableSource>
    | Improve this Doc View Source

    EnumerateAccessibleTables(SelectQuery)

    Declaration
    public static IEnumerable<SqlTable> EnumerateAccessibleTables(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<SqlTable>
    | Improve this Doc View Source

    EnumerateInnerJoined(SelectQuery)

    Declaration
    public static IEnumerable<SqlTableSource> EnumerateInnerJoined(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<SqlTableSource>
    | Improve this Doc View Source

    EnumerateInnerJoined(SqlTableSource)

    Declaration
    public static IEnumerable<SqlTableSource> EnumerateInnerJoined(SqlTableSource tableSource)
    Parameters
    Type Name Description
    SqlTableSource tableSource
    Returns
    Type Description
    IEnumerable<SqlTableSource>
    | Improve this Doc View Source

    EnumerateJoins(SelectQuery)

    Declaration
    public static IEnumerable<SqlJoinedTable> EnumerateJoins(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<SqlJoinedTable>
    | Improve this Doc View Source

    EnumerateJoins(SqlTableSource)

    Declaration
    public static IEnumerable<SqlJoinedTable> EnumerateJoins(SqlTableSource tableSource)
    Parameters
    Type Name Description
    SqlTableSource tableSource
    Returns
    Type Description
    IEnumerable<SqlJoinedTable>
    | Improve this Doc View Source

    EnumerateLevelSources(SelectQuery)

    Declaration
    public static IEnumerable<ISqlTableSource> EnumerateLevelSources(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<ISqlTableSource>
    | Improve this Doc View Source

    EnumerateLevelSources(SqlTableSource)

    Declaration
    public static IEnumerable<ISqlTableSource> EnumerateLevelSources(SqlTableSource tableSource)
    Parameters
    Type Name Description
    SqlTableSource tableSource
    Returns
    Type Description
    IEnumerable<ISqlTableSource>
    | Improve this Doc View Source

    EnumerateLevelTables(SelectQuery)

    Declaration
    public static IEnumerable<SqlTable> EnumerateLevelTables(SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    Returns
    Type Description
    IEnumerable<SqlTable>
    | Improve this Doc View Source

    EvaluateBoolExpression(IQueryElement, EvaluationContext, bool?)

    Declaration
    public static bool? EvaluateBoolExpression(this IQueryElement expr, EvaluationContext context, bool? defaultValue = null)
    Parameters
    Type Name Description
    IQueryElement expr
    EvaluationContext context
    bool? defaultValue
    Returns
    Type Description
    bool?
    | Improve this Doc View Source

    EvaluateExpression(IQueryElement, EvaluationContext)

    Declaration
    public static object? EvaluateExpression(this IQueryElement expr, EvaluationContext context)
    Parameters
    Type Name Description
    IQueryElement expr
    EvaluationContext context
    Returns
    Type Description
    object
    | Improve this Doc View Source

    ExtractField(ISqlExpression)

    Returns SqlField from specific expression. Usually from SqlColumn. Conversion is ignored.

    Declaration
    public static SqlField? ExtractField(ISqlExpression expression)
    Parameters
    Type Name Description
    ISqlExpression expression
    Returns
    Type Description
    SqlField

    Field instance associated with expression

    | Improve this Doc View Source

    FindJoin(SelectQuery, Func<SqlJoinedTable, bool>)

    Declaration
    public static SqlJoinedTable? FindJoin(this SelectQuery query, Func<SqlJoinedTable, bool> match)
    Parameters
    Type Name Description
    SelectQuery query
    Func<SqlJoinedTable, bool> match
    Returns
    Type Description
    SqlJoinedTable
    | Improve this Doc View Source

    GenerateEquality(ISqlExpression, ISqlExpression, bool)

    Declaration
    public static SqlCondition GenerateEquality(ISqlExpression field1, ISqlExpression field2, bool compareNullsAsValues)
    Parameters
    Type Name Description
    ISqlExpression field1
    ISqlExpression field2
    bool compareNullsAsValues
    Returns
    Type Description
    SqlCondition
    | Improve this Doc View Source

    GetBoolValue(ISqlExpression, EvaluationContext)

    Declaration
    public static bool? GetBoolValue(ISqlExpression expression, EvaluationContext context)
    Parameters
    Type Name Description
    ISqlExpression expression
    EvaluationContext context
    Returns
    Type Description
    bool?
    | Improve this Doc View Source

    GetColumnDescriptor(ISqlExpression?)

    Returns ColumnDescriptor for expr.

    Declaration
    public static ColumnDescriptor? GetColumnDescriptor(ISqlExpression? expr)
    Parameters
    Type Name Description
    ISqlExpression expr

    Tested SQL Expression.

    Returns
    Type Description
    ColumnDescriptor

    Associated column descriptor or null.

    | Improve this Doc View Source

    GetDbDataType(ISqlExpression?)

    Declaration
    public static DbDataType GetDbDataType(ISqlExpression? expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    DbDataType
    | Improve this Doc View Source

    GetDeleteTable(SqlDeleteStatement)

    Declaration
    public static SqlTable? GetDeleteTable(this SqlDeleteStatement deleteStatement)
    Parameters
    Type Name Description
    SqlDeleteStatement deleteStatement
    Returns
    Type Description
    SqlTable
    | Improve this Doc View Source

    GetExpressionType(ISqlExpression)

    Declaration
    public static DbDataType GetExpressionType(this ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    DbDataType
    | Improve this Doc View Source

    GetParameterValue(SqlParameter, IReadOnlyParameterValues?)

    Declaration
    public static SqlParameterValue GetParameterValue(this SqlParameter parameter, IReadOnlyParameterValues? parameterValues)
    Parameters
    Type Name Description
    SqlParameter parameter
    IReadOnlyParameterValues parameterValues
    Returns
    Type Description
    SqlParameterValue
    | Improve this Doc View Source

    GetUnderlyingExpression(ISqlExpression?)

    Unwraps SqlColumn and returns underlying expression.

    Declaration
    public static ISqlExpression? GetUnderlyingExpression(ISqlExpression? expression)
    Parameters
    Type Name Description
    ISqlExpression expression
    Returns
    Type Description
    ISqlExpression

    Underlying expression.

    | Improve this Doc View Source

    GetUnderlyingExpressionValue(SqlExpression, bool)

    Declaration
    public static ISqlExpression GetUnderlyingExpressionValue(SqlExpression sqlExpression, bool checkNullability)
    Parameters
    Type Name Description
    SqlExpression sqlExpression
    bool checkNullability
    Returns
    Type Description
    ISqlExpression
    | Improve this Doc View Source

    GetUnderlyingField(ISqlExpression)

    Returns SqlField from specific expression. Usually from SqlColumn. Complex expressions ignored.

    Declaration
    public static SqlField? GetUnderlyingField(ISqlExpression expression)
    Parameters
    Type Name Description
    ISqlExpression expression
    Returns
    Type Description
    SqlField

    Field instance associated with expression

    | Improve this Doc View Source

    GetUpdateTable(SqlUpdateStatement)

    Declaration
    public static SqlTable? GetUpdateTable(this SqlUpdateStatement updateStatement)
    Parameters
    Type Name Description
    SqlUpdateStatement updateStatement
    Returns
    Type Description
    SqlTable
    | Improve this Doc View Source

    GetUsedSources(ISqlExpression, HashSet<ISqlTableSource>)

    Retrieves which sources are used in the rootexpression

    Declaration
    public static void GetUsedSources(ISqlExpression root, HashSet<ISqlTableSource> foundSources)
    Parameters
    Type Name Description
    ISqlExpression root

    Expression to analyze.

    HashSet<ISqlTableSource> foundSources

    Output container for detected sources/

    | Improve this Doc View Source

    GetValueConverter(ISqlExpression?)

    Returns IValueConverter for expr.

    Declaration
    public static IValueConverter? GetValueConverter(ISqlExpression? expr)
    Parameters
    Type Name Description
    ISqlExpression expr

    Tested SQL Expression.

    Returns
    Type Description
    IValueConverter

    Associated converter or null.

    | Improve this Doc View Source

    HasOuterReferences(ISet<ISqlTableSource>, ISqlExpression)

    Declaration
    public static bool HasOuterReferences(ISet<ISqlTableSource> sources, ISqlExpression expr)
    Parameters
    Type Name Description
    ISet<ISqlTableSource> sources
    ISqlExpression expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    HasQueryParameters(ISqlExpression)

    Declaration
    public static bool HasQueryParameters(ISqlExpression expression)
    Parameters
    Type Name Description
    ISqlExpression expression
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsAggregationFunction(IQueryElement)

    Declaration
    public static bool IsAggregationFunction(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsAggregationOrWindowFunction(IQueryElement)

    Declaration
    public static bool IsAggregationOrWindowFunction(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsComplexExpression(ISqlExpression)

    Declaration
    public static bool IsComplexExpression(this ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsConstant(ISqlExpression)

    Returns true if tested expression is constant during query execution (e.g. value or parameter).

    Declaration
    public static bool IsConstant(ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr

    Tested expression.

    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsConstantFast(ISqlExpression)

    Declaration
    public static bool IsConstantFast(ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsDependsOn(IQueryElement, IQueryElement, HashSet<IQueryElement>?)

    Declaration
    public static bool IsDependsOn(IQueryElement testedRoot, IQueryElement onElement, HashSet<IQueryElement>? elementsToIgnore = null)
    Parameters
    Type Name Description
    IQueryElement testedRoot
    IQueryElement onElement
    HashSet<IQueryElement> elementsToIgnore
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsDependsOn(IQueryElement, HashSet<ISqlTableSource>, HashSet<IQueryElement>?)

    Declaration
    public static bool IsDependsOn(IQueryElement testedRoot, HashSet<ISqlTableSource> onSources, HashSet<IQueryElement>? elementsToIgnore = null)
    Parameters
    Type Name Description
    IQueryElement testedRoot
    HashSet<ISqlTableSource> onSources
    HashSet<IQueryElement> elementsToIgnore
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsEqualTables(SqlTable?, SqlTable?)

    Declaration
    public static bool IsEqualTables(SqlTable? table1, SqlTable? table2)
    Parameters
    Type Name Description
    SqlTable table1
    SqlTable table2
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsExpression(ISqlExpression)

    Returns true if it is anything except Field or Column.

    Declaration
    public static bool IsExpression(ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr

    Tested expression

    Returns
    Type Description
    bool

    true if tested expression is not a Field or Column

    | Improve this Doc View Source

    IsMutable(IQueryElement)

    Declaration
    public static bool IsMutable(this IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsTransitiveExpression(SqlExpression, bool)

    Declaration
    public static bool IsTransitiveExpression(SqlExpression sqlExpression, bool checkNullability)
    Parameters
    Type Name Description
    SqlExpression sqlExpression
    bool checkNullability
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    IsWindowFunction(IQueryElement)

    Declaration
    public static bool IsWindowFunction(IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    JoinRemoval<TContext>(TContext, SqlStatement, Func<TContext, SqlStatement, SqlJoinedTable, bool>)

    Removes Join from query based on joinFunc result.

    Declaration
    public static SqlStatement JoinRemoval<TContext>(TContext context, SqlStatement statement, Func<TContext, SqlStatement, SqlJoinedTable, bool> joinFunc)
    Parameters
    Type Name Description
    TContext context

    joinFunc context object.

    SqlStatement statement

    Source statement.

    Func<TContext, SqlStatement, SqlJoinedTable, bool> joinFunc
    Returns
    Type Description
    SqlStatement

    Same or new statement with removed joins.

    Type Parameters
    Name Description
    TContext
    | Improve this Doc View Source

    MoveOrderByUp(params SelectQuery[])

    Helper function for moving Ordering up in select tree.

    Declaration
    public static void MoveOrderByUp(params SelectQuery[] queries)
    Parameters
    Type Name Description
    SelectQuery[] queries

    Array of queries

    | Improve this Doc View Source

    MoveSearchConditionsToJoin(SelectQuery, SqlJoinedTable, List<SqlCondition>?)

    Declaration
    public static void MoveSearchConditionsToJoin(SelectQuery sql, SqlJoinedTable joinedTable, List<SqlCondition>? movedConditions)
    Parameters
    Type Name Description
    SelectQuery sql
    SqlJoinedTable joinedTable
    List<SqlCondition> movedConditions
    | Improve this Doc View Source

    NeedColumnForExpression(SelectQuery, ISqlExpression, bool)

    Returns correct column or field according to nesting.

    Declaration
    public static ISqlExpression? NeedColumnForExpression(SelectQuery selectQuery, ISqlExpression forExpression, bool inProjection)
    Parameters
    Type Name Description
    SelectQuery selectQuery

    Analyzed query.

    ISqlExpression forExpression

    Expression that has to be enveloped by column.

    bool inProjection

    If 'true', function ensures that column is created. If 'false' it may return Field if it fits to nesting level.

    Returns
    Type Description
    ISqlExpression

    Returns Column of Field according to its nesting level. May return null if expression is not valid for selectQuery

    | Improve this Doc View Source

    NeedParameterInlining(ISqlExpression)

    Declaration
    public static bool NeedParameterInlining(ISqlExpression expression)
    Parameters
    Type Name Description
    ISqlExpression expression
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    RemoveNotUnusedColumns(SelectQuery)

    Declaration
    public static void RemoveNotUnusedColumns(this SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    | Improve this Doc View Source

    RootQuery(SelectQuery)

    Declaration
    public static SelectQuery RootQuery(this SelectQuery query)
    Parameters
    Type Name Description
    SelectQuery query
    Returns
    Type Description
    SelectQuery
    | Improve this Doc View Source

    ShouldCheckForNull(ISqlExpression)

    Declaration
    public static bool ShouldCheckForNull(this ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    SuggestDbDataType(ISqlExpression)

    Declaration
    public static DbDataType? SuggestDbDataType(ISqlExpression expr)
    Parameters
    Type Name Description
    ISqlExpression expr
    Returns
    Type Description
    DbDataType?
    | Improve this Doc View Source

    ToDebugString(IQueryElement)

    Declaration
    public static string ToDebugString(this IQueryElement expr)
    Parameters
    Type Name Description
    IQueryElement expr
    Returns
    Type Description
    string
    | Improve this Doc View Source

    TransformExpressionIndexes<TContext>(TContext, string, Func<TContext, int, int>)

    Declaration
    public static string TransformExpressionIndexes<TContext>(TContext context, string expression, Func<TContext, int, int> transformFunc)
    Parameters
    Type Name Description
    TContext context
    string expression
    Func<TContext, int, int> transformFunc
    Returns
    Type Description
    string
    Type Parameters
    Name Description
    TContext
    | Improve this Doc View Source

    TransformInnerJoinsToWhere(SelectQuery)

    Transforms SELECT * FROM A INNER JOIN B ON A.ID = B.ID to SELECT * FROM A, B WHERE A.ID = B.ID

    Declaration
    public static SelectQuery TransformInnerJoinsToWhere(this SelectQuery selectQuery)
    Parameters
    Type Name Description
    SelectQuery selectQuery

    Input SelectQuery.

    Returns
    Type Description
    SelectQuery

    The same query instance.

    | Improve this Doc View Source

    TryConvertOrderedDistinctToGroupBy(SelectQuery, SqlProviderFlags)

    Converts ORDER BY DISTINCT to GROUP BY equivalent

    Declaration
    public static bool TryConvertOrderedDistinctToGroupBy(SelectQuery select, SqlProviderFlags flags)
    Parameters
    Type Name Description
    SelectQuery select
    SqlProviderFlags flags
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    TryEvaluateExpression(IQueryElement, EvaluationContext, out object?)

    Declaration
    public static bool TryEvaluateExpression(this IQueryElement expr, EvaluationContext context, out object? result)
    Parameters
    Type Name Description
    IQueryElement expr
    EvaluationContext context
    object result
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    TryRemoveDistinct(SelectQuery, QueryInformation)

    Detects when we can remove order

    Declaration
    public static bool TryRemoveDistinct(SelectQuery selectQuery, QueryInformation information)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    QueryInformation information
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    UnwrapExpression(ISqlExpression, bool)

    Declaration
    public static ISqlExpression UnwrapExpression(ISqlExpression expr, bool checkNullability)
    Parameters
    Type Name Description
    ISqlExpression expr
    bool checkNullability
    Returns
    Type Description
    ISqlExpression
    | Improve this Doc View Source

    ValidateTable(SelectQuery, ISqlTableSource)

    Declaration
    public static bool ValidateTable(SelectQuery selectQuery, ISqlTableSource table)
    Parameters
    Type Name Description
    SelectQuery selectQuery
    ISqlTableSource table
    Returns
    Type Description
    bool
    | Improve this Doc View Source

    WrapQuery<TStatement>(TStatement, SelectQuery, bool)

    Wraps queryToWrap by another select. Keeps columns count the same. After modification statement is equivalent symantically.

    --before
    SELECT c1, c2
    FROM A
    -- after
    SELECT B.c1, B.c2
    FROM (
      SELECT c1, c2
      FROM A
         ) B
    Declaration
    public static TStatement WrapQuery<TStatement>(TStatement statement, SelectQuery queryToWrap, bool allowMutation) where TStatement : SqlStatement
    Parameters
    Type Name Description
    TStatement statement

    Statement which may contain tested query

    SelectQuery queryToWrap

    Tells which select query needs enveloping

    bool allowMutation

    Wrapped query can be not recreated for performance considerations.

    Returns
    Type Description
    TStatement

    The same statement or modified statement when wrapping has been performed.

    Type Parameters
    Name Description
    TStatement
    | Improve this Doc View Source

    WrapQuery<TStatement, TContext>(TContext, TStatement, Func<TContext, SelectQuery, IQueryElement?, bool>, Action<TContext, SelectQuery, SelectQuery>?, bool, bool)

    Wraps queries by another select. Keeps columns count the same. After modification statement is equivalent symantically.

    Declaration
    public static TStatement WrapQuery<TStatement, TContext>(TContext context, TStatement statement, Func<TContext, SelectQuery, IQueryElement?, bool> wrapTest, Action<TContext, SelectQuery, SelectQuery>? onWrap, bool allowMutation, bool withStack) where TStatement : SqlStatement
    Parameters
    Type Name Description
    TContext context

    onWrap and wrapTest context object.

    TStatement statement
    Func<TContext, SelectQuery, IQueryElement, bool> wrapTest

    Delegate for testing when query needs to be wrapped.

    Action<TContext, SelectQuery, SelectQuery> onWrap

    After enveloping query this function called for prcess needed optimizations.

    bool allowMutation

    Wrapped query can be not recreated for performance considerations.

    bool withStack

    Must be set to true, if wrapTest function use 3rd parameter (containing parent element) otherwise it will be always null.

    Returns
    Type Description
    TStatement

    The same statement or modified statement when wrapping has been performed.

    Type Parameters
    Name Description
    TStatement
    TContext

    Type of onWrap and wrapTest context object.

    | Improve this Doc View Source

    WrapQuery<TStatement, TContext>(TContext, TStatement, Func<TContext, SelectQuery, IQueryElement?, int>, Action<TContext, IReadOnlyList<SelectQuery>>, bool, bool)

    Wraps tested query in subquery(s). Keeps columns count the same. After modification statement is equivalent semantically.

    --before
    SELECT c1, c2           -- QA
    FROM A
    -- after (with 2 subqueries)
    SELECT C.c1, C.c2       -- QC
    FROM (
      SELECT B.c1, B.c2     -- QB
      FROM (
        SELECT c1, c2       -- QA
        FROM A
           ) B
      FROM
         ) C
    Declaration
    public static TStatement WrapQuery<TStatement, TContext>(TContext context, TStatement statement, Func<TContext, SelectQuery, IQueryElement?, int> wrapTest, Action<TContext, IReadOnlyList<SelectQuery>> onWrap, bool allowMutation, bool withStack) where TStatement : SqlStatement
    Parameters
    Type Name Description
    TContext context

    onWrap and wrapTest context object.

    TStatement statement

    Statement which may contain tested query

    Func<TContext, SelectQuery, IQueryElement, int> wrapTest

    Delegate for testing which query needs to be enveloped. Result of delegate call tells how many subqueries needed. 0 - no changes 1 - one subquery N - N subqueries

    Action<TContext, IReadOnlyList<SelectQuery>> onWrap

    After wrapping query this function called for prcess needed optimizations. Array of queries contains [QC, QB, QA]

    bool allowMutation

    Wrapped query can be not recreated for performance considerations.

    bool withStack

    Must be set to true, if wrapTest function use 3rd parameter (containing parent element) otherwise it will be always null.

    Returns
    Type Description
    TStatement

    The same statement or modified statement when wrapping has been performed.

    Type Parameters
    Name Description
    TStatement
    TContext

    Type of onWrap and wrapTest context object.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2011-2023 linq2db.com

    Generated by DocFX