protected override async Task InitializeAsync(StatementContext context) { var lowerBound = await LowerBound.ReduceToConstantAsync(context); var upperBound = await UpperBound.ReduceToConstantAsync(context); context.Metadata["lowerBound"] = lowerBound; context.Metadata["upperBound"] = upperBound; if (Reverse) { context.AssignVariable(IndexName, SqlExpression.Constant(upperBound)); } else { context.AssignVariable(IndexName, SqlExpression.Constant(lowerBound)); } await base.InitializeAsync(context); }
protected override async Task ExecuteStatementAsync(StatementContext context) { try { var value = await context.AssignVariable(Variable, Value).ReduceToConstantAsync(context); context.SetResult(value); } catch (SqlExpressionException ex) { throw new SqlStatementException($"Could not assign the variable '{Variable}' because of an error", ex); } catch (Exception ex) { throw new SqlStatementException($"Could not assign the variable '{Variable}' because of an error", ex); } }
protected override Task ExecuteStatementAsync(StatementContext context) { try { var value = context.AssignVariable(Variable, Value); context.SetResult(value); } catch (SqlExpressionException ex) { throw new SqlStatementException($"Could not assign the variable '{Variable}' because of an error", ex); } catch (Exception ex) { throw new SqlStatementException($"Could not assign the variable '{Variable}' because of an error", ex); } return(Task.CompletedTask); }