18 using System.Collections.Generic;
24 namespace Deveel.Data.Routines {
30 private Dictionary<string, DataObject>
output;
34 throw new ArgumentNullException(
"invoke");
36 throw new ArgumentNullException(
"routine");
39 GroupResolver = group;
40 VariableResolver = resolver;
88 if (evaluatedArgs == null) {
89 evaluatedArgs =
new DataObject[Arguments.Length];
90 for (
int i = 0; i < Arguments.Length; i++) {
91 evaluatedArgs[i] = Arguments[i].EvaluateToConstant(Request, VariableResolver);
103 public int ArgumentCount {
104 get {
return Arguments == null ? 0 : Arguments.Length; }
108 var parameter =
Routine.RoutineInfo.Parameters.FirstOrDefault(x => x.Name.Equals(argName, StringComparison.Ordinal));
109 if (parameter == null) {
114 var offset = parameter.Offset;
115 if (parameter.IsUnbounded) {
128 if (!TryGetArgument(argName, out exp)) {
133 value = exp.EvaluateToConstant(Request, VariableResolver);
138 throw new NotImplementedException();
143 throw new InvalidOperationException(
"The routine is not a function.");
150 throw new InvalidOperationException(
"The routine is not a procedure: a return value is required.");
156 return Routine.RoutineInfo.Parameters.FirstOrDefault(x => x.Name.Equals(name, StringComparison.Ordinal));
160 var parameter = GetParameter(argName);
161 if (parameter == null)
162 throw new InvalidOperationException(String.Format(
"Routine {0} has none parameter named '{1}'.",
Routine.FullName, argName));
163 if (!parameter.IsOutput)
164 throw new InvalidOperationException();
166 if (!parameter.IsNullable &&
168 throw new ArgumentException();
170 if (!parameter.IsUnbounded)
171 throw new ArgumentException();
173 if (!parameter.Type.IsComparable(value.
Type))
174 throw new ArgumentException();
177 output =
new Dictionary<string, DataObject>();
179 output[argName] = value;
185 evaluatedArgs = null;
191 GC.SuppressFinalize(
this);
bool IsNull
Gets a value that indicates if this object is materialized as null.
SqlType Type
Gets the SqlType that defines the object properties
SqlExpression[] Arguments
Gets an array of arguments to be passed to the invoked routine.
static DataObject Null(SqlType type)
static SqlTupleExpression Tuple(SqlExpression[] expressions)
bool TryGetArgument(string argName, out SqlExpression value)
The contract to define a program routine that can interact with database objects. ...
RoutineParameter GetParameter(string name)
void Dispose(bool disposing)
A routine (PROCEDURE or FUNCTION) defined in a database, that is a program with defined input paramet...
RoutineType
The type of routine program.
bool TryGetArgument(string argName, out DataObject value)
Defines a contract used by grouping functions to find information about the current group being evalu...
Represents the result of the execution of a routine.
bool HasArgument(string argName)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
void SetOutput(string argName, DataObject value)
The information about the invocation of a routine, including the full name and arguments (as SqlExpre...
An interface to resolve a variable name to a constant object.
DataObject[] evaluatedArgs
InvokeResult Result(DataObject value)
Dictionary< string, DataObject > output
Defines the base class for instances that represent SQL expression tree nodes.
InvokeContext(Invoke invoke, IRoutine routine, IVariableResolver resolver, IGroupResolver group, IRequest request)