Esempio n. 1
0
 public override IAliasedExpression Visit(JoinedTableExpression item)
 {
     if (item.On.RightExpression is NLinq.Expressions.MemberExpression)
     {
         Visit(item.On.LeftExpression);
         referencePath.Length = 0;
         NLinq.Expressions.MemberExpression propertyReference = (NLinq.Expressions.MemberExpression)item.On.RightExpression;
         IAliasedExpression join = (IAliasedExpression)Visit(propertyReference);
         //if (loadedReferences.ContainsKey(((EntityIdentifier)item.On.LeftExpression).Text))
         //{
         //    AliasesMapping.Add(loadedReferences[((EntityIdentifier)item.On.LeftExpression).Text], lastAliasDefined);
         loadedReferences[((EntityIdentifier)item.On.LeftExpression).Text] = lastAliasDefined;
         //}
         //else
         //    loadedReferences.Add(((EntityIdentifier)item.On.LeftExpression).Text, lastAliasDefined);
         if (!AliasesMapping.ContainsKey(item.RightTable.Alias))
             AliasesMapping.Add(item.RightTable.Alias, join.Alias);
         return join;
     }
     return item;
 }
Esempio n. 2
0
 public virtual IAliasedExpression Update(JoinedTableExpression item, IAliasedExpression leftTable, IAliasedExpression rightTable, JoinType joinType, TableAlias alias, Evaluant.NLinq.Expressions.BinaryExpression on)
 {
     if (item.LeftTable != leftTable || item.RightTable != rightTable || item.JoinType != joinType || item.Alias != alias)
         return new JoinedTableExpression(leftTable, rightTable, joinType, alias, on);
     return item;
 }
Esempio n. 3
0
        private void BuildConstraint(Evaluant.Uss.SqlMapper.Mapping.Reference rm, out TableAlias firstAlias)
        {
            BinaryExpression on = null;
            JoinedTableExpression join = null;
            TableAlias lastAlias = null;
            firstAlias = new LazyTableAlias(rm.Rules[0].ParentTable);
            foreach (Mapping.Rule rule in rm.Rules)
            {
                JoinedTableExpression tempJoin = new JoinedTableExpression(new TableSourceExpression(lastAlias ?? firstAlias, rule.ParentTable), new TableSourceExpression(new TableAlias(), rule.ChildTable));

                BinaryExpression tempOn = null;
                for (int i = 0; i < rule.ParentFields.Count; i++)
                {
                    Field parentField = rule.ParentFields[i];
                    Field childField = rule.ChildFields[i];
                    BinaryExpression localOn = new BinaryExpression(BinaryExpressionType.Equal,
                        new ColumnExpression(tempJoin.LeftTable.Alias, parentField.ColumnName),
                        new ColumnExpression(tempJoin.RightTable.Alias, childField.ColumnName));
                    if (tempOn == null)
                        tempOn = localOn;
                    else
                        tempOn = new BinaryExpression(BinaryExpressionType.And, tempOn, localOn);
                }
                tempJoin.On = tempOn;
                if (join != null)
                    tempJoin.LeftTable = join;
                lastAlias = tempJoin.RightTable.Alias;
                join = tempJoin;
                if (on == null)
                    on = tempOn;
                else
                    on = new BinaryExpression(BinaryExpressionType.And, on, tempOn);

            }
            joins[rm] = join;
            ons[rm] = on;
        }