Search Results for

    Show / Hide Table of Contents

    Class Sql.ExpressionAttribute

    An Attribute that allows custom Expressions to be defined for a Method used within a Linq Expression.

    Inheritance
    System.Object
    MappingAttribute
    Sql.ExpressionAttribute
    Sql.ExtensionAttribute
    Sql.FunctionAttribute
    Sql.PropertyAttribute
    Namespace: LinqToDB
    Assembly: linq2db.dll
    Syntax
    public class ExpressionAttribute : MappingAttribute

    Constructors

    | Improve this Doc View Source

    ExpressionAttribute(Nullable<String>)

    Creates an Expression that will be used in SQL, in place of the method call decorated by this attribute.

    Declaration
    public ExpressionAttribute(string? expression)
    Parameters
    Type Name Description
    System.Nullable<System.String> expression

    The SQL expression. Use {0},{1}... for parameters given to the method call.

    | Improve this Doc View Source

    ExpressionAttribute(String, Int32[])

    Creates an Expression that will be used in SQL, in place of the method call decorated by this attribute.

    Declaration
    public ExpressionAttribute(string expression, params int[] argIndices)
    Parameters
    Type Name Description
    System.String expression

    The SQL expression. Use {0},{1}... for parameters given to the method call.

    System.Int32[] argIndices

    Used for setting the order of the method arguments being passed into the function.

    | Improve this Doc View Source

    ExpressionAttribute(String, String)

    Creates an Expression that will be used in SQL, for the ProviderName specified, in place of the method call decorated by this attribute.

    Declaration
    public ExpressionAttribute(string configuration, string expression)
    Parameters
    Type Name Description
    System.String configuration

    The Database configuration for which this Expression will be used.

    System.String expression

    The SQL expression. Use {0},{1}... for parameters given to the method call.

    | Improve this Doc View Source

    ExpressionAttribute(String, String, Int32[])

    Creates an Expression that will be used in SQL, for the ProviderName specified, in place of the method call decorated by this attribute.

    Declaration
    public ExpressionAttribute(string configuration, string expression, params int[] argIndices)
    Parameters
    Type Name Description
    System.String configuration

    The Database configuration for which this Expression will be used.

    System.String expression

    The SQL expression. Use {0},{1}... for parameters given to the method call.

    System.Int32[] argIndices

    Used for setting the order of the method arguments being passed into the function.

    Fields

    | Improve this Doc View Source

    UnknownExpression

    Declaration
    public static readonly SqlExpression UnknownExpression
    Field Value
    Type Description
    SqlExpression

    Properties

    | Improve this Doc View Source

    ArgIndices

    The order of Arguments to be passed into the function from the method call.

    Declaration
    public int[] ArgIndices { get; set; }
    Property Value
    Type Description
    System.Int32[]
    | Improve this Doc View Source

    CanBeNull

    If true, result can be null

    Declaration
    public bool CanBeNull { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Configuration

    If null, this will be treated as the default evaluation for the expression. If set to a ProviderName, It will only be used for that provider configuration.

    Declaration
    public string? Configuration { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    ExpectExpression

    Used internally by Sql.ExtensionAttribute.

    Declaration
    public bool ExpectExpression { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Expression

    The expression to be used in building the SQL.

    Declaration
    public string? Expression { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    IgnoreGenericParameters

    if true, do not generate generic parameters.

    Declaration
    public bool IgnoreGenericParameters { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    InlineParameters

    If true inline all parameters passed into the expression.

    Declaration
    public bool InlineParameters { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsAggregate

    If true, this expression represents an aggregate result Examples would be SUM(),COUNT().

    Declaration
    public bool IsAggregate { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsNullable

    Used to determine whether the return type should be treated as something that can be null If CanBeNull is not explicitly set.

    Default is Undefined, which will be treated as true

    Declaration
    public Sql.IsNullableType IsNullable { get; set; }
    Property Value
    Type Description
    Sql.IsNullableType
    | Improve this Doc View Source

    IsPredicate

    If true the expression is treated as a Predicate And when used in a Where clause will not have an added comparison to 'true' in the database.

    Declaration
    public bool IsPredicate { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsPure

    If true, it notifies SQL Optimizer that expression returns same result if the same values/parameters are used. It gives optimizer additional information how to simplify query. For example ORDER BY PureFunction("Str") can be removed because PureFunction function uses constant value. For example Random function is NOT Pure function because it returns different result all time. But expression CurrentTimestamp is Pure in case of executed query. is also Pure function because it returns the same result with the same parameters.

    Declaration
    public bool IsPure { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsWindowFunction

    If true, this expression represents a Window Function Examples would be SUM() OVER(), COUNT() OVER().

    Declaration
    public bool IsWindowFunction { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Precedence

    Determines the priority of the expression in evaluation. Refer to Precedence.

    Declaration
    public int Precedence { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    PreferServerSide

    If true a greater effort will be made to execute the expression on the DB server instead of in .NET.

    Declaration
    public bool PreferServerSide { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ServerSideOnly

    If true The expression will only be evaluated on the database server. If it cannot, an exception will be thrown.

    Declaration
    public bool ServerSideOnly { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    CalcCanBeNull(Sql.IsNullableType, IEnumerable<Boolean>)

    Declaration
    public static bool? CalcCanBeNull(Sql.IsNullableType isNullable, IEnumerable<bool> nullInfo)
    Parameters
    Type Name Description
    Sql.IsNullableType isNullable
    IEnumerable<System.Boolean> nullInfo
    Returns
    Type Description
    System.Nullable<System.Boolean>
    | Improve this Doc View Source

    GetCanBeNull(ISqlExpression[])

    Declaration
    protected bool GetCanBeNull(ISqlExpression[] parameters)
    Parameters
    Type Name Description
    ISqlExpression[] parameters
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetExpression<TContext>(TContext, IDataContext, SelectQuery, Expression, Func<TContext, Expression, ColumnDescriptor, ISqlExpression>)

    Declaration
    public virtual ISqlExpression GetExpression<TContext>(TContext context, IDataContext dataContext, SelectQuery query, Expression expression, Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter)
    Parameters
    Type Name Description
    TContext context
    IDataContext dataContext
    SelectQuery query
    Expression expression
    Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter
    Returns
    Type Description
    ISqlExpression
    Type Parameters
    Name Description
    TContext
    | Improve this Doc View Source

    GetIsPredicate(Expression)

    Declaration
    public virtual bool GetIsPredicate(Expression expression)
    Parameters
    Type Name Description
    Expression expression
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetObjectID()

    Declaration
    public override string GetObjectID()
    Returns
    Type Description
    System.String
    Overrides
    MappingAttribute.GetObjectID()
    | Improve this Doc View Source

    PrepareArguments<TContext>(TContext, String, Int32[], Boolean, List<Nullable<Expression>>, Nullable<List<SqlDataType>>, Func<TContext, Expression, ColumnDescriptor, ISqlExpression>)

    Declaration
    public static ISqlExpression[] PrepareArguments<TContext>(TContext context, string expressionStr, int[] argIndices, bool addDefault, List<Expression?> knownExpressions, List<SqlDataType>? genericTypes, Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter)
    Parameters
    Type Name Description
    TContext context
    System.String expressionStr
    System.Int32[] argIndices
    System.Boolean addDefault
    List<System.Nullable<Expression>> knownExpressions
    System.Nullable<List<SqlDataType>> genericTypes
    Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter
    Returns
    Type Description
    ISqlExpression[]
    Type Parameters
    Name Description
    TContext
    | Improve this Doc View Source

    PrepareParameterValues<TContext>(TContext, MappingSchema, Expression, ref Nullable<String>, Boolean, out List<Nullable<Expression>>, Boolean, out Nullable<List<SqlDataType>>, Func<TContext, Expression, ColumnDescriptor, ISqlExpression>)

    Declaration
    public static void PrepareParameterValues<TContext>(TContext context, MappingSchema mappingSchema, Expression expression, ref string? expressionStr, bool includeInstance, out List<Expression?> knownExpressions, bool ignoreGenericParameters, out List<SqlDataType>? genericTypes, Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter)
    Parameters
    Type Name Description
    TContext context
    MappingSchema mappingSchema
    Expression expression
    System.Nullable<System.String> expressionStr
    System.Boolean includeInstance
    List<System.Nullable<Expression>> knownExpressions
    System.Boolean ignoreGenericParameters
    System.Nullable<List<SqlDataType>> genericTypes
    Func<TContext, Expression, ColumnDescriptor, ISqlExpression> converter
    Type Parameters
    Name Description
    TContext
    | Improve this Doc View Source

    ResolveExpressionValues<TContext>(TContext, String, Func<TContext, String, Nullable<String>, Nullable<String>>)

    Declaration
    public static string ResolveExpressionValues<TContext>(TContext context, string expression, Func<TContext, string, string?, string?> valueProvider)
    Parameters
    Type Name Description
    TContext context
    System.String expression
    Func<TContext, System.String, System.Nullable<System.String>, System.Nullable<System.String>> valueProvider
    Returns
    Type Description
    System.String
    Type Parameters
    Name Description
    TContext

    Extension Methods

    Map.DeepCopy<T>(T)
    Sql.IsDistinctFrom<T>(T, T)
    Sql.IsNotDistinctFrom<T>(T, T)
    SqlExtensions.In<T>(T, IEnumerable<T>)
    SqlExtensions.In<T>(T, IQueryable<T>)
    SqlExtensions.In<T>(T, T[])
    SqlExtensions.In<T>(T, T, T)
    SqlExtensions.In<T>(T, T, T, T)
    SqlExtensions.NotIn<T>(T, IEnumerable<T>)
    SqlExtensions.NotIn<T>(T, IQueryable<T>)
    SqlExtensions.NotIn<T>(T, T[])
    SqlExtensions.NotIn<T>(T, T, T)
    SqlExtensions.NotIn<T>(T, T, T, T)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2011-2022 linq2db.com

    Generated by DocFX