示例#1
0
 public override Evaluant.NLinq.Expressions.QueryBodyClause Visit(NLinq.Expressions.FromClause expression)
 {
     TableAlias alias;
     if (entityIdentifierAliases.TryGetValue(expression.Identifier.Text, out alias))
     {
         if (alias != ((EntityIdentifier)expression.Identifier).Entity.Alias)
             throw new NotSupportedException("The same identifier refers to a different Alias");
     }
     else
         entityIdentifierAliases.Add(expression.Identifier.Text, ((EntityIdentifier)expression.Identifier).Entity.Alias);
     if (expression.Type != null)
     {
         IAliasedExpression src;
         if (expression.Type.StartsWith("System."))
             src = ((EntityIdentifier)expression.Identifier).Entity;
         else
             src = new SqlExpressions.Mapping.EntitySourceExpression(((EntityIdentifier)expression.Identifier).Entity.Alias, expression.Type);
         if (select.From == null)
             select.From = new FromClause(src);
         else
             select.From = new FromClause(
                 new JoinedTableExpression(
                     select.From[0],
                     src,
                     new Evaluant.NLinq.Expressions.BinaryExpression(
                           Evaluant.NLinq.Expressions.BinaryExpressionType.Unknown,
                           expression.Identifier,
                           Visit(expression.Expression))
                     )
                 );
     }
     else
     {
         SelectStatement currentSelect = select;
         var result = Visit(expression.Expression);
         if (select != currentSelect)
         {
             select = (SelectStatement)new LazyAliasResolver(new Dictionary<TableAlias, TableAlias> { { select.Alias, ((EntityIdentifier)expression.Identifier).Entity.Alias } }).Visit(select);
             if (currentSelect.From == null)
                 currentSelect.From = new FromClause(select);
             else
                 currentSelect.From = new FromClause(
                     new JoinedTableExpression(
                         currentSelect.From[0],
                         select,
                         new NLinq.Expressions.BinaryExpression(
                             NLinq.Expressions.BinaryExpressionType.Unknown,
                             expression.Identifier,
                             result)
                         )
                     );
         }
         select = currentSelect;
     }
     return expression;
 }
示例#2
0
 public DiscriminatorMutator(SqlExpressions.Mapping.EntitySourceExpression ese)
 {
     this.ese = ese;
 }