Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ExternalDatabase.cs
1using System;
2using System.Threading.Tasks;
7
9{
13 public abstract class ExternalDatabase : IDatabaseConnection
14 {
19 {
20 }
21
25 public virtual void Dispose()
26 {
27 }
28
34 public abstract Task<IElement> ExecuteSqlStatement(string Statement);
35
41 public abstract Task<IElement> GetSchema(string Name);
42
48 public abstract Task<ILambdaExpression> GetProcedure(string Name);
49
55 public Task<ILambdaExpression> this[string Name] => this.GetProcedure(Name);
56
60 public virtual int NrArguments => 1;
61
65 public virtual string[] ArgumentNames => new string[] { "SQL" };
66
70 public ArgumentType[] ArgumentTypes => argumentTypes1Parameters;
71
72 private static readonly ArgumentType[] argumentTypes1Parameters = new ArgumentType[] { ArgumentType.Scalar };
73
78 public bool IsAsynchronous => true;
79
87 {
88 return this.EvaluateAsync(Arguments, Variables).Result;
89 }
90
97 public Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
98 {
99 if (!(Arguments[0]?.AssociatedObjectValue is string SqlStatement))
100 throw new ScriptRuntimeException("Argument must be a string.", null);
101
102 return this.ExecuteSqlStatement(SqlStatement);
103 }
104
106 public override string ToString()
107 {
108 return LambdaDefinition.ToString(this);
109 }
110 }
111}
Abstract base class for external databases
IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the lambda expression.
abstract Task< ILambdaExpression > GetProcedure(string Name)
Creates a lambda expression for accessing a stored procedure.
virtual int NrArguments
Number of arguments.
abstract Task< IElement > GetSchema(string Name)
Gets a Schema table, given its collection name.
ArgumentType[] ArgumentTypes
Argument types.
ExternalDatabase()
Abstract base class for external databases
Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the lambda expression.
virtual void Dispose()
IDisposable.Dispose
bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
abstract Task< IElement > ExecuteSqlStatement(string Statement)
Executes an SQL Statement on the database.
virtual string[] ArgumentNames
Argument Names.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Interface for database connections
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9