DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | List of all members
Deveel.Data.Sql.Expressions.SqlExpressionExtensions Class Reference

Extension methods to SqlExpression More...

Static Public Member Functions

static ObjectName AsReferenceName (this SqlExpression expression)
 Extracts the name of the reference from the expression. More...
 
static IQueryPlanNode AsQueryPlan (this SqlExpression expression)
 
static DataObject EvaluateToConstant (this SqlExpression expression, EvaluateContext context)
 Evaluates the expression and reduces to a constant expression, whose value is then returned. More...
 
static DataObject EvaluateToConstant (this SqlExpression expression, IRequest request, IVariableResolver variableResolver)
 
static SqlType ReturnType (this SqlExpression expression, IRequest query, IVariableResolver variableResolver)
 Gets the return type of the expression when evaluated. More...
 
static bool HasAggregate (this SqlExpression expression, IRequest query)
 Verifies if the expression contains any aggregate function in the tree. More...
 
static bool IsConstant (this SqlExpression expression)
 

Detailed Description

Extension methods to SqlExpression

Definition at line 28 of file SqlExpressionExtensions.cs.

Member Function Documentation

static IQueryPlanNode Deveel.Data.Sql.Expressions.SqlExpressionExtensions.AsQueryPlan ( this SqlExpression  expression)
inlinestatic

Definition at line 45 of file SqlExpressionExtensions.cs.

45  {
46  var constantExp = expression as SqlConstantExpression;
47  if (constantExp == null)
48  return null;
49 
50  var value = constantExp.Value;
51  if (value.Value is SqlQueryObject)
52  return ((SqlQueryObject) value.Value).QueryPlan;
53 
54  return null;
55  }
static ObjectName Deveel.Data.Sql.Expressions.SqlExpressionExtensions.AsReferenceName ( this SqlExpression  expression)
inlinestatic

Extracts the name of the reference from the expression.

Parameters
expressionThe expression that encapsulates the reference
Returns
Returns an ObjectName instance if the given expression is a SqlReferenceExpression, otherwise it returns null.

Definition at line 37 of file SqlExpressionExtensions.cs.

37  {
38  var refExpression = expression as SqlReferenceExpression;
39  if (refExpression == null)
40  return null;
41 
42  return refExpression.ReferenceName;
43  }
static DataObject Deveel.Data.Sql.Expressions.SqlExpressionExtensions.EvaluateToConstant ( this SqlExpression  expression,
EvaluateContext  context 
)
inlinestatic

Evaluates the expression and reduces to a constant expression, whose value is then returned.

Parameters
expressionThe expression to evaluate.
contextThe context used to evaluate the expression.
Returns
Returns a DataObject is the result of the SqlExpression.Evaluate(Deveel.Data.Sql.Expressions.EvaluateContext) is a SqlConstantExpression.
Exceptions
InvalidOperationExceptionIf the expression could not be evaluated or if the result of the evaluation is not a SqlConstantExpression.
See also
SqlExpression.Evaluate(Deveel.Data.Sql.Expressions.EvaluateContext), SqlConstantExpression, SqlConstantExpression.Value

Definition at line 75 of file SqlExpressionExtensions.cs.

75  {
76  var evalExp = expression.Evaluate(context);
77  if (evalExp == null)
78  throw new InvalidOperationException();
79 
80  var constantExp = evalExp as SqlConstantExpression;
81  if (constantExp == null)
82  throw new InvalidOperationException();
83 
84  return constantExp.Value;
85  }
static DataObject Deveel.Data.Sql.Expressions.SqlExpressionExtensions.EvaluateToConstant ( this SqlExpression  expression,
IRequest  request,
IVariableResolver  variableResolver 
)
inlinestatic

Definition at line 87 of file SqlExpressionExtensions.cs.

87  {
88  return expression.EvaluateToConstant(new EvaluateContext(request, variableResolver));
89  }
static bool Deveel.Data.Sql.Expressions.SqlExpressionExtensions.HasAggregate ( this SqlExpression  expression,
IRequest  query 
)
inlinestatic

Verifies if the expression contains any aggregate function in the tree.

Parameters
expressionThe expression to verify.
query
Returns
Returns true if the expression has any aggregate function in its tree, or false otherwise.

Definition at line 118 of file SqlExpressionExtensions.cs.

118  {
119  var visitor = new AggregateChecker(query);
120  return visitor.HasAggregate(expression);
121  }
static bool Deveel.Data.Sql.Expressions.SqlExpressionExtensions.IsConstant ( this SqlExpression  expression)
inlinestatic

Definition at line 123 of file SqlExpressionExtensions.cs.

123  {
124  var visitor = new ConstantVisitor();
125  visitor.Visit(expression);
126  return visitor.IsConstant;
127  }
static SqlType Deveel.Data.Sql.Expressions.SqlExpressionExtensions.ReturnType ( this SqlExpression  expression,
IRequest  query,
IVariableResolver  variableResolver 
)
inlinestatic

Gets the return type of the expression when evaluated.

Parameters
expressionThe expression to check.
queryThe query context used to evaluate the return type of the expression.
variableResolverThe object used to resolve variable references in the expression tree.
Returns
Returns the SqlType that an evaluation of the expression would return, or null if the final result of the evaluation has no return type.

Definition at line 103 of file SqlExpressionExtensions.cs.

103  {
104  var visitor = new ReturnTypeVisitor(query, variableResolver);
105  return visitor.GetType(expression);
106  }

The documentation for this class was generated from the following file: