/// <summary>Adds an outer join descriptor that defines how the streams are related via outer joins. <para /> For joining Count streams, add Count-1 outer join qualifiers. </summary> /// <param name="outerJoinQualifier">is the type of outer join and the fields in the outer join</param> /// <returns>from clause</returns> public FromClause Add(OuterJoinQualifier outerJoinQualifier) { OuterJoinQualifiers.Add(outerJoinQualifier); return(this); }
/// <summary>Creates a from-clause that lists 2 projected streams joined via outer join. </summary> /// <param name="stream">first stream in outer join</param> /// <param name="outerJoinQualifier">qualifies the outer join</param> /// <param name="streamSecond">second stream in outer join</param> /// <returns>from clause</returns> public static FromClause Create(Stream stream, OuterJoinQualifier outerJoinQualifier, Stream streamSecond) { return(new FromClause(stream, outerJoinQualifier, streamSecond)); }
/// <summary>Ctor for an outer join between two streams. </summary> /// <param name="streamOne">first stream in outer join</param> /// <param name="outerJoinQualifier">type of outer join and fields joined on</param> /// <param name="streamTwo">second stream in outer join</param> public FromClause(Stream streamOne, OuterJoinQualifier outerJoinQualifier, Stream streamTwo) : this(streamOne) { Add(streamTwo); OuterJoinQualifiers.Add(outerJoinQualifier); }
/// <summary>Renders the from-clause in textual representation. </summary> /// <param name="writer">to output to</param> /// <param name="includeFrom">flag whether to add the "from" literal</param> /// <param name="formatter">for NewLine-whitespace formatting</param> public void ToEPLOptions(TextWriter writer, EPStatementFormatter formatter, bool includeFrom) { String delimiter = ""; if (includeFrom) { formatter.BeginFrom(writer); writer.Write("from"); } if ((OuterJoinQualifiers == null) || (OuterJoinQualifiers.Count == 0)) { bool first = true; foreach (Stream stream in Streams) { writer.Write(delimiter); formatter.BeginFromStream(writer, first); first = false; stream.ToEPL(writer, formatter); delimiter = ","; } } else { if (OuterJoinQualifiers.Count != (Streams.Count - 1)) { throw new ArgumentException("Number of outer join qualifiers must be one less then the number of streams."); } bool first = true; for (int i = 0; i < Streams.Count; i++) { Stream stream = Streams[i]; formatter.BeginFromStream(writer, first); first = false; stream.ToEPL(writer, formatter); if (i > 0) { OuterJoinQualifier qualCond = OuterJoinQualifiers[i - 1]; if (qualCond.Left != null) { writer.Write(" on "); qualCond.Left.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM); writer.Write(" = "); qualCond.Right.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM); if (qualCond.AdditionalProperties.Count > 0) { foreach (PropertyValueExpressionPair pair in qualCond.AdditionalProperties) { writer.Write(" and "); pair.Left.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM); writer.Write(" = "); pair.Right.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM); } } } } if (i < Streams.Count - 1) { OuterJoinQualifier qualType = OuterJoinQualifiers[i]; writer.Write(" "); writer.Write(qualType.JoinType.GetText()); writer.Write(" outer join"); } } } }