public override int GetHashCode() { unchecked { int hash = Key.GetHashCode(); hash = (hash * 397) ^ Operator.GetHashCode(); hash = (hash * 397) ^ (Value != null ? Value.GetHashCode() : 0); hash = (hash * 397) ^ QueryJoin.GetHashCode(); return(hash); } }
public override void Convert(dynamic jsonItem, ref QueryContainer query) { //Tablolar arası ilişkiler dönüştürülüyor if (jsonItem != null) { foreach (var j in jsonItem.Value) { var _joinType = JoinType.INNER; if (j.Name == "inner") { _joinType = JoinType.INNER; } if (j.Name == "left") { _joinType = JoinType.LEFT; } if (j.Name == "right") { _joinType = JoinType.RIGHT; } if (j.Value != null) { foreach (var item in j.Value) { var join = new QueryJoin(); join.joinType = _joinType; join.Destination = item.Name; join.Target = item.Value; query.Join.Add(join); } } } } }
public override Node VisitQueryJoin(QueryJoin join) { join.LeftOperand = this.VisitExpression(join.LeftOperand); Composer left = this.GetComposer(join.LeftOperand); join.RightOperand = this.VisitExpression(join.RightOperand); Composer right = this.GetComposer(join.RightOperand); Composer save = this.contextComposer; this.contextComposer = left; if (this.contextComposer == null) { this.contextComposer = right; } bool savehcr = this.hasContextReference; this.hasContextReference = false; join.JoinExpression = this.VisitExpression(join.JoinExpression); this.hasContextReference = savehcr; this.contextComposer = save; return(this.Compose(join, left, right)); }
public virtual Node VisitQueryJoin(QueryJoin join){ if (join == null) return null; join.LeftOperand = this.VisitExpression(join.LeftOperand); join.RightOperand = this.VisitExpression(join.RightOperand); join.JoinExpression = this.VisitExpression(join.JoinExpression); return join; }
public override Node VisitQueryJoin(QueryJoin qj) { if (qj == null) return null; Class cc = this.currentMethod.Scope.ClosureClass; qj.LeftOperand = this.VisitExpression(qj.LeftOperand); qj.RightOperand = this.VisitExpression(qj.RightOperand); if (qj.LeftOperand == null || qj.LeftOperand.Type == null || qj.RightOperand == null || qj.RightOperand.Type == null) return null; Cardinality card = this.typeSystem.GetCardinality(qj.LeftOperand, this.TypeViewer); if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) { this.HandleError(qj.LeftOperand, Error.QueryNotStream); return null; } card = this.typeSystem.GetCardinality(qj.RightOperand, this.TypeViewer); if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) { this.HandleError(qj.RightOperand, Error.QueryNotStream); return null; } if (qj.JoinExpression != null) { qj.JoinExpression = this.VisitBooleanExpression(qj.JoinExpression); if (qj.JoinExpression == null || qj.JoinExpression.Type == null) return null; } if (qj.Type == null) return null; return qj; }
public override Node VisitQueryJoin(QueryJoin join){ if (join == null) return null; join.LeftOperand = this.VisitExpression(join.LeftOperand); join.RightOperand = this.VisitExpression(join.RightOperand); TypeNode leftType = this.typeSystem.GetStreamElementType(join.LeftOperand, this.TypeViewer); TypeNode rightType = this.typeSystem.GetStreamElementType(join.RightOperand, this.TypeViewer); if (join.LeftOperand != null && leftType != null && join.RightOperand != null && rightType != null){ if (join.JoinType == QueryJoinType.RightOuter || join.JoinType == QueryJoinType.FullOuter){ leftType = SystemTypes.GenericBoxed.GetTemplateInstance(this.currentType, leftType); } if (join.JoinType == QueryJoinType.LeftOuter || join.JoinType == QueryJoinType.FullOuter){ rightType = SystemTypes.GenericBoxed.GetTemplateInstance(this.currentType, rightType); } Field leftField = this.NewField(Identifier.For("Item0"), leftType, Anonymity.Full); Field rightField = this.NewField(Identifier.For("Item1"), rightType, Anonymity.Full); TypeNode joinedType = TupleType.For(new FieldList(leftField, rightField), this.currentType); if (join.JoinExpression != null){ join.JoinContext = this.contextScope = new ContextScope(this.contextScope, joinedType); join.JoinExpression = this.VisitExpression(join.JoinExpression); this.contextScope = this.contextScope.Previous; } join.Type = SystemTypes.GenericIEnumerable.GetTemplateInstance(this.currentType, joinedType); } return join; }
private static void Test_Add_Join(QueryJoin join, Func <IQueryParts, IImmutableList <(IColumn from, IColumn to)> > getJoin)
public virtual void VisitQueryJoin(QueryJoin join){ if (join == null) return; this.VisitExpression(join.LeftOperand); this.VisitExpression(join.RightOperand); this.VisitExpression(join.JoinExpression); }
public override Node VisitQueryJoin(QueryJoin join){ if (join == null) return null; return base.VisitQueryJoin((QueryJoin)join.Clone()); }
public virtual Node VisitQueryJoin(QueryJoin join1, QueryJoin join2){ if (join1 == null) return null; if (join2 == null){ join1.LeftOperand = this.VisitExpression(join1.LeftOperand, null); join1.RightOperand = this.VisitExpression(join1.RightOperand, null); join1.JoinExpression = this.VisitExpression(join1.JoinExpression, null); }else{ join1.LeftOperand = this.VisitExpression(join1.LeftOperand, join2.LeftOperand); join1.RightOperand = this.VisitExpression(join1.RightOperand, join2.RightOperand); join1.JoinExpression = this.VisitExpression(join1.JoinExpression, join2.JoinExpression); } return join1; }
public void TestJoin() { var result = new QueryJoin(Session).Join(); Assert.AreEqual(30, result.Count); }
public override Node VisitQueryJoin(QueryJoin qj) { TypeNode joinedType = this.typeSystem.GetStreamElementType(qj, this.TypeViewer); Block block = null; Node closure = this.StartQueryClosure(joinedType, "join", out block); BlockScope scope = block.Scope; Expression leftTarget = null; Block leftBody = null; Statement feLeft = this.BuildClosureForEach(qj.LeftOperand, ref leftTarget, out leftBody, scope); Expression rightTarget = null; Block rightBody = null; Statement feRight = this.BuildClosureForEach(qj.RightOperand, ref rightTarget, out rightBody, scope); Expression joined = this.NewClosureLocal(joinedType, scope); MemberList joinedMembers = this.typeSystem.GetDataMembers(joinedType); Debug.Assert(joinedMembers.Count > 1); Member leftMember = joinedMembers[0]; Member rightMember = joinedMembers[1]; MemberBinding mbLeft = new MemberBinding(joined, leftMember); MemberBinding mbRight = new MemberBinding(joined, rightMember); mbLeft.Type = this.typeSystem.GetMemberType(leftMember); mbRight.Type = this.typeSystem.GetMemberType(rightMember); Block onFalse = new Block(); Block onExit = new Block(); if (qj.JoinContext != null) qj.JoinContext.Target = joined; switch( qj.JoinType ) { case QueryJoinType.Inner: block.Statements.Add(feLeft); leftBody.Statements.Add(feRight); rightBody.Statements.Add(new AssignmentStatement(mbLeft, this.typeSystem.ImplicitCoercion(leftTarget, mbLeft.Type, this.TypeViewer))); rightBody.Statements.Add(new AssignmentStatement(mbRight, this.typeSystem.ImplicitCoercion(rightTarget, mbRight.Type, this.TypeViewer))); if (qj.JoinExpression != null) { rightBody.Statements.Add(new Branch(new UnaryExpression(qj.JoinExpression, NodeType.LogicalNot), onFalse)); rightBody.Statements.Add(new Yield(joined)); rightBody.Statements.Add(onFalse); } else { rightBody.Statements.Add(new Yield(joined)); } break; case QueryJoinType.LeftOuter: block.Statements.Add(feLeft); Expression hadRight = this.NewClosureLocal(SystemTypes.Boolean, scope); leftBody.Statements.Add(new AssignmentStatement(hadRight, Literal.False)); leftBody.Statements.Add(feRight); rightBody.Statements.Add(new AssignmentStatement(mbLeft, this.typeSystem.ImplicitCoercion(leftTarget, mbLeft.Type, this.TypeViewer))); rightBody.Statements.Add(new AssignmentStatement(mbRight, this.typeSystem.ImplicitCoercion(rightTarget, mbRight.Type, this.TypeViewer))); rightBody.Statements.Add(new Branch(new UnaryExpression(qj.JoinExpression, NodeType.LogicalNot), onFalse)); rightBody.Statements.Add(new AssignmentStatement(hadRight, Literal.True)); rightBody.Statements.Add(new Yield(joined)); rightBody.Statements.Add(onFalse); leftBody.Statements.Add(new Branch(hadRight, onExit)); leftBody.Statements.Add(new AssignmentStatement(mbRight, this.typeSystem.ImplicitCoercion(Literal.Null, mbRight.Type, this.TypeViewer))); leftBody.Statements.Add(new Yield(joined)); leftBody.Statements.Add(onExit); break; case QueryJoinType.RightOuter: block.Statements.Add(feRight); Expression hadLeft = this.NewClosureLocal(SystemTypes.Boolean, scope); rightBody.Statements.Add(new AssignmentStatement(hadLeft, Literal.False)); rightBody.Statements.Add(feLeft); leftBody.Statements.Add(new AssignmentStatement(mbLeft, this.typeSystem.ImplicitCoercion(leftTarget, mbLeft.Type, this.TypeViewer))); leftBody.Statements.Add(new AssignmentStatement(mbRight, this.typeSystem.ImplicitCoercion(rightTarget, mbRight.Type, this.TypeViewer))); leftBody.Statements.Add(new Branch(new UnaryExpression(qj.JoinExpression, NodeType.LogicalNot), onFalse)); leftBody.Statements.Add(new AssignmentStatement(hadLeft, Literal.True)); leftBody.Statements.Add(new Yield(joined)); leftBody.Statements.Add(onFalse); rightBody.Statements.Add(new Branch(hadLeft, onExit)); rightBody.Statements.Add(new AssignmentStatement(mbLeft, this.typeSystem.ImplicitCoercion(Literal.Null, mbLeft.Type, this.TypeViewer))); rightBody.Statements.Add(new Yield(joined)); rightBody.Statements.Add(onExit); break; case QueryJoinType.FullOuter: break; } return this.EndQueryClosure(closure, qj.Type); }
public override Node VisitQueryJoin( QueryJoin join ){ Scope scope = this.scope; Scope leftScope = this.scope = new QueryScope(scope); this.AddToAllScopes(this.scope); join.LeftOperand = this.VisitExpression(join.LeftOperand); Scope rightScope = this.scope = new QueryScope(scope); this.AddToAllScopes(this.scope); join.RightOperand = this.VisitExpression(join.RightOperand); this.MoveMembers(scope, leftScope.Members); this.MoveMembers(scope, rightScope.Members); this.scope = scope; join.JoinExpression = this.VisitExpression(join.JoinExpression); return join; }
public override Node VisitQueryJoin(QueryJoin join) { join.LeftOperand = this.VisitExpression(join.LeftOperand); Composer left = this.GetComposer(join.LeftOperand); join.RightOperand = this.VisitExpression(join.RightOperand); Composer right = this.GetComposer(join.RightOperand); Composer save = this.contextComposer; this.contextComposer = left; if (this.contextComposer == null) this.contextComposer = right; bool savehcr = this.hasContextReference; this.hasContextReference = false; join.JoinExpression = this.VisitExpression(join.JoinExpression); this.hasContextReference = savehcr; this.contextComposer = save; return this.Compose(join, left, right); }
public virtual Differences VisitQueryJoin(QueryJoin join1, QueryJoin join2){ Differences differences = new Differences(join1, join2); if (join1 == null || join2 == null){ if (join1 != join2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } QueryJoin changes = (QueryJoin)join2.Clone(); QueryJoin deletions = (QueryJoin)join2.Clone(); QueryJoin insertions = (QueryJoin)join2.Clone(); // join1.JoinContext; // join1.JoinExpression; // join1.JoinType; // join1.LeftOperand; // join1.RightOperand; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public virtual Node VisitQueryJoin(QueryJoin join, QueryJoin changes, QueryJoin deletions, QueryJoin insertions){ this.UpdateSourceContext(join, changes); if (join == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return join; }
public EventingVisitor(Action<QueryJoin> visitQueryJoin) { VisitedQueryJoin += visitQueryJoin; } public event Action<QueryJoin> VisitedQueryJoin; public override Node VisitQueryJoin(QueryJoin join) { if (VisitedQueryJoin != null) VisitedQueryJoin(join); return base.VisitQueryJoin(join); }