Table of Contents

Class Sql.ExtensionAttribute

Namespace
LinqToDB
Assembly
linq2db.dll
[AttributeUsage(AttributeTargets.Method|AttributeTargets.Property, AllowMultiple = true)]
public class Sql.ExtensionAttribute : Sql.ExpressionAttribute, _Attribute
Inheritance
object
Sql.ExtensionAttribute
Implements
Inherited Members
Extension Methods

Constructors

ExtensionAttribute(string)

public ExtensionAttribute(string expression)

Parameters

expression string

ExtensionAttribute(string, string)

public ExtensionAttribute(string configuration, string expression)

Parameters

configuration string
expression string

ExtensionAttribute(string, Type)

public ExtensionAttribute(string configuration, Type builderType)

Parameters

configuration string
builderType Type

ExtensionAttribute(Type)

public ExtensionAttribute(Type builderType)

Parameters

builderType Type

Properties

BuilderType

public Type? BuilderType { get; set; }

Property Value

Type

BuilderValue

public object? BuilderValue { get; set; }

Property Value

object

ChainPrecedence

Defines in which order process extensions. Items will be ordered Descending.

public int ChainPrecedence { get; set; }

Property Value

int

TokenName

public string? TokenName { get; set; }

Property Value

string

Methods

BuildFunctionsChain<TContext>(TContext, IDataContext, IExpressionEvaluator, SelectQuery, Expression, ConvertFunc<TContext>, out Expression?)

protected List<Sql.SqlExtensionParam>? BuildFunctionsChain<TContext>(TContext context, IDataContext dataContext, IExpressionEvaluator evaluator, SelectQuery query, Expression expr, Sql.ExpressionAttribute.ConvertFunc<TContext> converter, out Expression? error)

Parameters

context TContext
dataContext IDataContext
evaluator IExpressionEvaluator
query SelectQuery
expr Expression
converter Sql.ExpressionAttribute.ConvertFunc<TContext>
error Expression

Returns

List<Sql.SqlExtensionParam>

Type Parameters

TContext

BuildSqlExpression(MappingSchema, SelectQuery, SqlExtension, Type, int, SqlFlags, bool?, IsNullableType)

public static Expression BuildSqlExpression(MappingSchema mappingSchema, SelectQuery query, Sql.SqlExtension root, Type systemType, int precedence, SqlFlags flags, bool? canBeNull, Sql.IsNullableType isNullable)

Parameters

mappingSchema MappingSchema
query SelectQuery
root Sql.SqlExtension
systemType Type
precedence int
flags SqlFlags
canBeNull bool?
isNullable Sql.IsNullableType

Returns

Expression

ExcludeExtensionChain(MappingSchema, Expression, out bool)

public static Expression ExcludeExtensionChain(MappingSchema mapping, Expression expr, out bool isQueryable)

Parameters

mapping MappingSchema
expr Expression
isQueryable bool

Returns

Expression

GetExpression<TContext>(TContext, IDataContext, IExpressionEvaluator, SelectQuery, Expression, ConvertFunc<TContext>)

Builds SQL for the extension member or method call.

public override Expression GetExpression<TContext>(TContext context, IDataContext dataContext, IExpressionEvaluator evaluator, SelectQuery query, Expression expression, Sql.ExpressionAttribute.ConvertFunc<TContext> converter)

Parameters

context TContext

Context, passed to converter on each call.

dataContext IDataContext

Data context, which query is built for.

evaluator IExpressionEvaluator

Evaluator, used to calculate values of client-side expressions.

query SelectQuery

Query, which the extension belongs to.

expression Expression

Extension member or method call expression.

converter Sql.ExpressionAttribute.ConvertFunc<TContext>

Function, which translates an expression to SQL. An expression, which it translates successfully, has its value supplied to the database through a parameter, which is re-read from the query expression on every execution, or through an inlined literal, which the parameters context registers for comparison. Either way the extension does not have to make it a part of the query cache key itself. Value, which is read instead of being translated, is baked into generated SQL and has to be compared on query cache lookup - see GetExpression(int, bool, bool?).

Returns

Expression

Expression with generated SQL, or an error expression when the extension cannot be translated.

Type Parameters

TContext

Type of the context, passed to converter.

GetExtensionAttributes(Expression, MappingSchema, bool)

public static Sql.ExtensionAttribute[] GetExtensionAttributes(Expression expression, MappingSchema mapping, bool forFirstConfiguration = true)

Parameters

expression Expression
mapping MappingSchema
forFirstConfiguration bool

Returns

ExtensionAttribute[]

GetObjectID()

Returns mapping attribute id, based on all attribute options.

public override string GetObjectID()

Returns

string