3using System.Threading.Tasks;
40 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
43 KeyValuePair<VariableReference, bool>[] LeftOrder = await
Reduce(this.
Left, Order);
50 e =
new InnerJoinEnumerator(e, this.
Left.
Name,
this.Right,
this.Right.Name, Generic, RightWhere,
Variables);
58 if (Top !=
int.MaxValue)
70 private readonly
string leftName;
71 private readonly
string rightName;
72 private readonly
bool hasLeftName;
73 private readonly
bool generic;
82 this.leftName = LeftName;
83 this.rightName = RightName;
84 this.rightSource = RightSource;
85 this.generic = Generic;
88 this.hasLeftName = !
string.IsNullOrEmpty(this.leftName);
91 public object Current => this.current;
98 public bool MoveNext()
100 return this.MoveNextAsync().Result;
103 public async Task<bool> MoveNextAsync()
107 if (!(this.right is
null))
111 this.current =
new JoinedObject(this.left.Current,
this.leftName,
112 this.right.Current,
this.rightName);
120 if (!await this.left.MoveNextAsync())
123 if (this.leftVariables is
null)
124 this.leftVariables =
new ObjectProperties(this.left.Current,
this.variables);
126 this.leftVariables.Object = this.left.Current;
128 if (this.hasLeftName)
129 this.leftVariables[this.leftName] = this.left.Current;
131 this.right = await this.rightSource.Find(0,
int.MaxValue, this.
generic, this.conditions, this.leftVariables,
132 null, this.conditions);
162 KeyValuePair<VariableReference, bool>[] LeftOrder = await
Reduce(this.Left, Order);
165 RightWhere = this.
Combine(RightWhere, this.Conditions);
167 if (Top !=
int.MaxValue)
173 if (!(Where is
null))
176 Processor =
new InnerJoinLeftProcessor(Processor, this.Left.Name,
this.Right,
177 this.Right.Name, Generic, RightWhere,
Variables);
179 return await this.Left.Process(Processor, 0,
int.MaxValue, Generic,
183 private class InnerJoinLeftProcessor :
IProcessor<object>
185 private readonly InnerJoinRightProcessor rightProcessor;
189 private readonly
string leftName;
190 private readonly
bool hasLeftName;
191 private readonly
bool generic;
195 IDataSource RightSource,
string RightName,
bool Generic,
198 this.rightProcessor =
new InnerJoinRightProcessor(Processor, LeftName, RightName);
199 this.leftName = LeftName;
200 this.rightSource = RightSource;
201 this.generic = Generic;
204 this.hasLeftName = !
string.IsNullOrEmpty(this.leftName);
207 public bool IsAsynchronous =>
true;
208 public bool Process(
object Object) => this.ProcessAsync(Object).Result;
209 public bool Flush() => this.rightProcessor.Flush();
210 public Task<bool> FlushAsync() => this.rightProcessor.FlushAsync();
212 public async Task<bool> ProcessAsync(
object Object)
214 if (this.leftVariables is
null)
217 this.leftVariables.Object = Object;
219 if (this.hasLeftName)
220 this.leftVariables[this.leftName] = Object;
222 this.rightProcessor.CurrentLeft = Object;
224 return await this.rightSource.Process(this.rightProcessor, 0,
int.MaxValue,
225 this.
generic, this.conditions, this.leftVariables,
null, this.conditions);
229 private class InnerJoinRightProcessor :
IProcessor<object>
232 private readonly
string leftName;
233 private readonly
string rightName;
238 this.processor = Processor;
239 this.leftName = LeftName;
240 this.rightName = RightName;
243 public object CurrentLeft {
get;
set; }
246 public bool Flush() => this.processor.Flush();
247 public Task<bool> FlushAsync() => this.processor.FlushAsync();
249 public bool Process(
object Object)
251 return this.processor.Process(
new JoinedObject(this.CurrentLeft,
252 this.leftName, Object, this.rightName));
257 return this.processor.ProcessAsync(
new JoinedObject(this.CurrentLeft,
258 this.leftName, Object, this.rightName));
Base class for all nodes in a parsed script tree.
Enumerator that only returns elements matching a set of conditions.
Enumerator that limits the return set to a maximum number of records.
Enumerator that skips a given number of result records.
Processor that only processes elements matching a set of conditions.
Processor that limits the return set to a maximum number of records.
Processor that skips a given number of result records.
Data source formed through an INNER JOIN of two sources.
InnerJoinedSource(IDataSource Left, IDataSource Right, ScriptNode Conditions)
Data source formed through an INNER JOIN of two sources.
override async Task< bool > Process(IProcessor< object > Processor, int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Processes objects matching filter conditions in Where .
override async Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
Represents a joined object.
Abstract base classes of joined sources.
ScriptNode Conditions
Conditions for join.
ScriptNode Combine(ScriptNode Where, ScriptNode On)
Combines one or two restrictions.
IDataSource Left
Left source
static async Task< ScriptNode > Reduce(IDataSource Source, ScriptNode Where)
Reduces a where clause to fit the current data source.
IDataSource Right
Right source
Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.
Interface for processors of objects.
bool IsAsynchronous
If the processor operates asynchronously.
Task< bool > ProcessAsync(T Object)
Processes an object asynchronously.
Interface for result-set enumerators.
Interface for data sources that can be used in SQL statements.
Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
string Name
Collection name or alias.