Table of Contents

Class Sql.FunctionAttribute

Namespace
LinqToDB
Assembly
linq2db.dll

Defines an SQL server-side Function with parameters passed in.

[Serializable]
[AttributeUsage(AttributeTargets.Method|AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
public class Sql.FunctionAttribute : Sql.ExpressionAttribute, _Attribute
Inheritance
object
Sql.FunctionAttribute
Implements
Inherited Members
Extension Methods

Constructors

FunctionAttribute()

Defines an SQL Function, which shall be the same as the name as the function called.

public FunctionAttribute()

FunctionAttribute(string)

Defines an SQL function with the given name.

public FunctionAttribute(string name)

Parameters

name string

The name of the function. no parenthesis () should be used.

FunctionAttribute(string, params int[])

Defines an SQL function with the given name.

public FunctionAttribute(string name, params int[] argIndices)

Parameters

name string

The name of the function. no parenthesis () should be used.

argIndices int[]

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

FunctionAttribute(string, string)

Defines an SQL function with the given name, for the ProviderName given.

public FunctionAttribute(string configuration, string name)

Parameters

configuration string

The Database configuration for which this Expression will be used.

name string

The name of the function. no parenthesis () should be used.

FunctionAttribute(string, string, params int[])

Defines an SQL function with the given name, for the ProviderName given.

public FunctionAttribute(string configuration, string name, params int[] argIndices)

Parameters

configuration string

The Database configuration for which this Expression will be used.

name string

The name of the function. no parenthesis () should be used.

argIndices int[]

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

Properties

Name

The name of the Database Function

public string? Name { get; set; }

Property Value

string

Methods

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.

GetObjectID()

Returns mapping attribute id, based on all attribute options.

public override string GetObjectID()

Returns

string