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
-
objectSql.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
namestringThe 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
namestringThe name of the function. no parenthesis () should be used.
argIndicesint[]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
configurationstringThe Database configuration for which this Expression will be used.
namestringThe 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
configurationstringThe Database configuration for which this Expression will be used.
namestringThe name of the function. no parenthesis () should be used.
argIndicesint[]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
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
contextTContextContext, passed to
converteron each call.dataContextIDataContextData context, which query is built for.
evaluatorIExpressionEvaluatorEvaluator, used to calculate values of client-side expressions.
querySelectQueryQuery, which the extension belongs to.
expressionExpressionExtension member or method call expression.
converterSql.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
TContextType of the context, passed to
converter.
GetObjectID()
Returns mapping attribute id, based on all attribute options.
public override string GetObjectID()