本文整理汇总了C#中Deveel.Data.Sql.Expressions.SqlExpression.EvaluateToConstant方法的典型用法代码示例。如果您正苦于以下问题:C# SqlExpression.EvaluateToConstant方法的具体用法?C# SqlExpression.EvaluateToConstant怎么用?C# SqlExpression.EvaluateToConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deveel.Data.Sql.Expressions.SqlExpression
的用法示例。
在下文中一共展示了SqlExpression.EvaluateToConstant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVariable
public static Variable SetVariable(this IContext context, string variableName, SqlExpression value)
{
var currentContext = context;
while (currentContext != null) {
if (currentContext is IVariableScope) {
var scope = (IVariableScope) currentContext;
if (scope.HasVariable(variableName)) {
// TODO: support also in-context evaluation
var constantValue = value.EvaluateToConstant(null, context.VariableResolver());
return scope.SetVariable(variableName, constantValue);
}
}
currentContext = currentContext.Parent;
}
currentContext = context;
while (currentContext != null) {
if (currentContext is IVariableScope) {
var scope = (IVariableScope)currentContext;
// TODO: support also in-context evaluation
var constantValue = value.EvaluateToConstant(null, context.VariableResolver());
return scope.SetVariable(variableName, constantValue);
}
currentContext = currentContext.Parent;
}
// not found in the hierarchy
return null;
}
示例2: Select
public static ITable Select(this ITable table, IQueryContext context, SqlExpression expression)
{
if (expression is SqlBinaryExpression) {
var binary = (SqlBinaryExpression)expression;
// Perform the pattern search expression on the table.
// Split the expression,
var leftRef = binary.Left.AsReferenceName();
if (leftRef != null)
// LHS is a simple variable so do a simple select
return table.SimpleSelect(context, leftRef, binary.ExpressionType, binary.Right);
}
// LHS must be a constant so we can just evaluate the expression
// and see if we get true, false, null, etc.
var v = expression.EvaluateToConstant(context, null);
// If it evaluates to NULL or FALSE then return an empty set
if (v.IsNull || v == false)
return table.EmptySelect();
return table;
}