Class Sql.ExtensionAttribute.ExtensionBuilder<TContext>
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
protected class Sql.ExtensionAttribute.ExtensionBuilder<TContext> : Sql.ISqlExtensionBuilder
Type Parameters
TContext
- Inheritance
-
objectSql.ExtensionAttribute.ExtensionBuilder<TContext>
- Implements
- Extension Methods
Constructors
ExtensionBuilder(TContext, IExpressionEvaluator, string?, object?, IDataContext, SelectQuery, SqlExtension, ConvertFunc<TContext>, MemberInfo, Expression[], IsNullableType, bool?)
public ExtensionBuilder(TContext context, IExpressionEvaluator evaluator, string? configuration, object? builderValue, IDataContext dataContext, SelectQuery query, Sql.SqlExtension extension, Sql.ExpressionAttribute.ConvertFunc<TContext> converter, MemberInfo member, Expression[] arguments, Sql.IsNullableType isNullable, bool? canBeNull)
Parameters
contextTContextevaluatorIExpressionEvaluatorconfigurationstringbuilderValueobjectdataContextIDataContextquerySelectQueryextensionSql.SqlExtensionconverterSql.ExpressionAttribute.ConvertFunc<TContext>memberMemberInfoargumentsExpression[]isNullableSql.IsNullableTypecanBeNullbool?
Properties
Arguments
public Expression[] Arguments { get; }
Property Value
BuilderValue
public object? BuilderValue { get; }
Property Value
- object
CanBeNull
public bool? CanBeNull { get; }
Property Value
- bool?
Configuration
public string? Configuration { get; }
Property Value
DataContext
public IDataContext DataContext { get; }
Property Value
Evaluator
public IExpressionEvaluator Evaluator { get; }
Property Value
Expression
public string Expression { get; set; }
Property Value
Extension
public Sql.SqlExtension Extension { get; }
Property Value
IsConvertible
public bool IsConvertible { get; set; }
Property Value
IsNullable
public Sql.IsNullableType IsNullable { get; }
Property Value
Mapping
public MappingSchema Mapping { get; }
Property Value
Member
public MemberInfo Member { get; }
Property Value
Method
public MethodInfo? Method { get; }
Property Value
Query
public SelectQuery Query { get; }
Property Value
ResultExpression
public ISqlExpression? ResultExpression { get; set; }
Property Value
Methods
AddParameter(string, ISqlExpression)
public Sql.SqlExtensionParam AddParameter(string name, ISqlExpression expr)
Parameters
namestringexprISqlExpression
Returns
ConvertExpression(Expression, bool, ColumnDescriptor?, bool?)
public ISqlExpression? ConvertExpression(Expression expr, bool unwrap, ColumnDescriptor? columnDescriptor, bool? inlineParameters)
Parameters
exprExpressionunwrapboolcolumnDescriptorColumnDescriptorinlineParametersbool?
Returns
ConvertExpressionToSql(Expression, bool, bool?)
public ISqlExpression? ConvertExpressionToSql(Expression expression, bool unwrap = false, bool? inlineParameters = null)
Parameters
expressionExpressionunwrapboolinlineParametersbool?
Returns
ConvertToSqlExpression()
public ISqlExpression? ConvertToSqlExpression()
Returns
ConvertToSqlExpression(int)
public ISqlExpression? ConvertToSqlExpression(int precedence)
Parameters
precedenceint
Returns
EvaluateExpression(Expression)
public object? EvaluateExpression(Expression expression)
Parameters
expressionExpression
Returns
- object
GetExpression(int, bool, bool?)
Translates extension method argument to SQL.
public ISqlExpression? GetExpression(int index, bool unwrap = false, bool? inlineParameters = null)
Parameters
indexintArgument position in the extension method call.
unwrapboolWhen true, conversion operators are removed from the argument expression before translation.
inlineParametersbool?When true, argument value is rendered as a literal instead of a parameter. null keeps current query setting.
Returns
- ISqlExpression
Argument SQL or null when argument cannot be translated.
Remarks
Translated argument travels to the database as a parameter, whose value is re-read from the query
expression on every execution, or as a literal when inlineParameters is
true, in which case the parameters context registers the value for comparison. Either
way the builder does not have to make it a part of the query cache key itself. Argument, read with
GetValue<T>(int) or taken from Arguments instead, is baked into generated
SQL by the builder, so it becomes a part of the query cache key.
GetExpression(string, bool, bool?)
Translates extension method argument to SQL.
public ISqlExpression? GetExpression(string argName, bool unwrap = false, bool? inlineParameters = null)
Parameters
argNamestringName of the extension method parameter.
unwrapboolWhen true, conversion operators are removed from the argument expression before translation.
inlineParametersbool?When true, argument value is rendered as a literal instead of a parameter. null keeps current query setting.
Returns
- ISqlExpression
Argument SQL or null when argument cannot be translated.
Remarks
Translated argument travels to the database as a parameter, whose value is re-read from the query
expression on every execution, or as a literal when inlineParameters is
true, in which case the parameters context registers the value for comparison. Either
way the builder does not have to make it a part of the query cache key itself. Argument, read with
GetValue<T>(string) or taken from Arguments instead, is baked into generated
SQL by the builder, so it becomes a part of the query cache key.
GetObjectValue(int)
public object GetObjectValue(int index)
Parameters
indexint
Returns
- object
GetObjectValue(string)
public object GetObjectValue(string argName)
Parameters
argNamestring
Returns
- object
GetValue<T>(int)
public T GetValue<T>(int index)
Parameters
indexint
Returns
- T
Type Parameters
T
Remarks
Read value is baked into generated SQL by the builder, so it becomes a part of the query cache key. See GetExpression(int, bool, bool?) for the translated-argument counterpart. Only the outermost call of a chained extension has its arguments registered, so a builder reading an argument of an inner element must mark it with SqlQueryDependentAttribute to keep the value in the key.
GetValue<T>(string)
public T GetValue<T>(string argName)
Parameters
argNamestring
Returns
- T
Type Parameters
T
Remarks
Read value is baked into generated SQL by the builder, so it becomes a part of the query cache key. See GetExpression(string, bool, bool?) for the translated-argument counterpart. Only the outermost call of a chained extension has its arguments registered, so a builder reading an argument of an inner element must mark it with SqlQueryDependentAttribute to keep the value in the key.