public SelectExpressionVisitor(TranslateContext context) : base(context)
 {
     _memberExpressions = new Stack <Expression>();
     _elementType       = context.EntityType;
     _Joins             = context.Joins;
     Columns            = new List <Column>();
 }
Exemple #2
0
 public JoinExpressionVisitor(TranslateContext context) : base(context)
 {
     Joins       = context.Joins;
     ExtraObject = new List <string>();
 }
 internal void Parse(Expression expression)
 {
     Distinct                = false;
     IsCallAny               = false;
     IsDelete                = false;
     IsUpdate                = false;
     UpdateResult            = new Dictionary <string, object>();
     _aggregationExpressions = new Dictionary <string, Expression>();
     Conditions              = new List <Token>();
     _nolockExpressions      = new List <Expression>();
     NoLockTables            = new List <string>();
     AggregationColumns      = new Dictionary <string, Column>();
     _sortExpressions        = new List <KeyValuePair <string, Expression> >();
     SortColumns             = new List <KeyValuePair <string, Column> >();
     _context                = new TranslateContext();
     _take = -1;
     _skip = -1;
     _context.EntityType = ElementType;
     Visit(expression);
     if (AggregationColumns.Count > 1)
     {
         throw new Exception();
     }
     if ((_skip != -1) && (_take != -1) &&
         !_sortExpressions.Any())
     {
         throw new Exception("分页必须进行排序");
     }
     foreach (MethodCallExpression expression2 in _joinExpressions)
     {
         VisitJoinExpression(expression2);
         break;
     }
     if (_selectExpression != null)
     {
         var operand = (_selectExpression as UnaryExpression).Operand as LambdaExpression;
         VisitSelectExpression(operand.Body);
     }
     else
     {
         VisitSelectExpression(null);
     }
     using (var enumerator = _whereExpressions.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             var body =
                 ((((MethodCallExpression)enumerator.Current).Arguments[1] as UnaryExpression).Operand as
                  LambdaExpression).Body;
             if (body is ConstantExpression)
             {
                 if (!(bool)(body as ConstantExpression).Value)
                 {
                     Conditions.Add(Token.Create(false));
                 }
             }
             else
             {
                 VisitWhereExpression(body);
             }
         }
     }
     foreach (var expression5 in _nolockExpressions)
     {
         VisitNoLockExpression(expression5);
     }
     foreach (var pair in _aggregationExpressions)
     {
         VisitAggreationExpression(pair);
     }
     foreach (var pair2 in _sortExpressions)
     {
         VisitSortExpression(pair2);
     }
     VisitUpdateExpression(_updateExpression);
 }
 public BinaryExpressionVisitor(TranslateContext context) : base(context)
 {
     _joins = context.Joins;
 }
Exemple #5
0
 public PropertyFieldExpressionVisitor(TranslateContext context) : base(context)
 {
     _memberInfos = new Stack <Expression>();
     _joins       = context.Joins;
     _columns     = context.Columns;
 }
 public ExpressionVisitorBase(TranslateContext context)
 {
     Context = context;
 }
 public MemberExpressionVisitor(TranslateContext context) : base(context)
 {
     _memberInfoStack = new Stack <MemberInfo>();
     _Joins           = context.Joins;
     SelectedColumn   = new Column();
 }
 public NoLockExpressionVisitor(TranslateContext context) : base(context)
 {
 }
 public MethodCallExpressionVisitor(TranslateContext context) : base(context)
 {
     _joins = context.Joins;
 }