本文整理汇总了C#中Deveel.Data.Sql.Expressions.SqlQueryExpression.EvaluateToConstant方法的典型用法代码示例。如果您正苦于以下问题:C# SqlQueryExpression.EvaluateToConstant方法的具体用法?C# SqlQueryExpression.EvaluateToConstant怎么用?C# SqlQueryExpression.EvaluateToConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deveel.Data.Sql.Expressions.SqlQueryExpression
的用法示例。
在下文中一共展示了SqlQueryExpression.EvaluateToConstant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteSelectAll
public void ExecuteSelectAll()
{
var expression =
new SqlQueryExpression(new[] {new SelectColumn(SqlExpression.Reference(new ObjectName("first_name")))});
expression.FromClause.AddTable("test_table");
Field result = null;
Assert.DoesNotThrow(() => result = expression.EvaluateToConstant(AdminQuery, null));
Assert.IsNotNull(result);
Assert.IsInstanceOf<QueryType>(result.Type);
Assert.IsNotNull(result.Value);
Assert.IsInstanceOf<SqlQueryObject>(result.Value);
ITable queryResult = null;
Assert.DoesNotThrow(() => queryResult = ((SqlQueryObject) result.Value).QueryPlan.Evaluate(AdminQuery));
Assert.IsNotNull(queryResult);
Assert.AreEqual(3, queryResult.RowCount);
}
示例2: DeleteFrom
public static int DeleteFrom(this IQuery context, ObjectName tableName, SqlQueryExpression query, int limit)
{
IQueryPlanNode plan;
try {
var planValue = query.EvaluateToConstant(context, null);
if (planValue == null)
throw new InvalidOperationException();
if (!(planValue.Type is QueryType))
throw new InvalidOperationException();
plan = ((SqlQueryObject)planValue.Value).QueryPlan;
} catch (QueryException) {
throw;
} catch (SecurityException) {
throw;
} catch (Exception ex) {
throw new InvalidOperationException(String.Format("Could not delete from table '{0}': unable to form the delete set.", tableName), ex);
}
var deleteSet = plan.Evaluate(context);
return context.DeleteFrom(tableName, deleteSet, limit);
}