//^invariant select != null ^ groupBy != null; public QueryBody(List <FromWhereClause> /*!*/ fromWhere, OrderByClause orderBy, object /*!*/ selectGroupBy, IntoClause into) { Debug.Assert(fromWhere != null && (selectGroupBy is SelectClause || selectGroupBy is GroupByClause)); this.fromWhere = fromWhere; this.orderBy = orderBy; this.select = selectGroupBy as SelectClause; this.groupBy = selectGroupBy as GroupByClause; this.into = into; }
private static LinqOpChain BuildSelectManyChain(List <Generator> /*!*/ generators, GroupByClause gbClause, Expression /*!*/ v, LinqOp lastOp) { // PATTERNs (Rules #6, #7): // from x1 in e1 from x2 in e3 ... from xk in ek [select v | group v by g] // // TRANSLATIONs: // ( e1 ) . SelectMany ( x1 => // ( e2 ) . SelectMany ( x2 => // ... // RESPECTIVELY: // ( ek ) . Select ( xk => v ) // ( ek ) . GroupBy ( xk => g, xk => v ) // ... // ) // ) // . [lastOp] int i = generators.Count - 1; LinqOp outer_op; // outer-most operator in the current chain if (gbClause != null) { outer_op = new LinqOp.GroupBy(generators[i].KeyVar, generators[i].ValueVar, gbClause.ByExpr, v); } else { outer_op = new LinqOp.Select(generators[i].KeyVar, generators[i].ValueVar, v); } // inner-most: LinqOpChain inner_chain = new LinqOpChain(generators[i].Expression, outer_op); while (--i >= 0) { inner_chain = new LinqOpChain( generators[i].Expression, outer_op = new LinqOp.SelectMany(generators[i].KeyVar, generators[i].ValueVar, inner_chain) ); } outer_op.Next = lastOp; return(inner_chain); }
public GroupBy(DirectVarUse keyVar, DirectVarUse valueVar, GroupByClause clause) : this(keyVar, valueVar, clause.GroupExpr, clause.ByExpr) { }
virtual public void VisitGroupByClause(Linq.GroupByClause x) { VisitElement(x.GroupExpr); VisitElement(x.ByExpr); }
private static LinqOpChain BuildSelectManyChain(List<Generator>/*!*/ generators, GroupByClause gbClause, Expression/*!*/ v, LinqOp lastOp) { // PATTERNs (Rules #6, #7): // from x1 in e1 from x2 in e3 ... from xk in ek [select v | group v by g] // // TRANSLATIONs: // ( e1 ) . SelectMany ( x1 => // ( e2 ) . SelectMany ( x2 => // ... // RESPECTIVELY: // ( ek ) . Select ( xk => v ) // ( ek ) . GroupBy ( xk => g, xk => v ) // ... // ) // ) // . [lastOp] int i = generators.Count - 1; LinqOp outer_op; // outer-most operator in the current chain if (gbClause != null) outer_op = new LinqOp.GroupBy(generators[i].KeyVar, generators[i].ValueVar, gbClause.ByExpr, v); else outer_op = new LinqOp.Select(generators[i].KeyVar, generators[i].ValueVar, v); // inner-most: LinqOpChain inner_chain = new LinqOpChain(generators[i].Expression, outer_op); while (--i >= 0) { inner_chain = new LinqOpChain( generators[i].Expression, outer_op = new LinqOp.SelectMany(generators[i].KeyVar, generators[i].ValueVar, inner_chain) ); } outer_op.Next = lastOp; return inner_chain; }
//^invariant select != null ^ groupBy != null; public QueryBody(List<FromWhereClause>/*!*/ fromWhere, OrderByClause orderBy, object/*!*/ selectGroupBy, IntoClause into) { Debug.Assert(fromWhere != null && (selectGroupBy is SelectClause || selectGroupBy is GroupByClause)); this.fromWhere = fromWhere; this.orderBy = orderBy; this.select = selectGroupBy as SelectClause; this.groupBy = selectGroupBy as GroupByClause; this.into = into; }