Example #1
0
        private static LinqOp BuildTupleOrderingOps(List <OrderingClause> clauses)
        {
            // tuple of size n + 1
            //
            // TRANSLATION:
            //  . OrderBy ( x => x[0] ) . ThenBy ( x => x[1] ) . ... . ThenBy ( x => x[n - 1] ) . Select ( x => x[n] )

            LinqOp last_op = new LinqOp.Select(null, null, new LinqTupleItemAccess(clauses.Count, clauses.Count + 1));

            for (int i = clauses.Count - 1; i >= 0; i--)
            {
                last_op = new LinqOp.OrderBy(null, null, new LinqTupleItemAccess(i, clauses.Count + 1), clauses[i].Ordering, last_op, i != 0);
            }

            return(last_op);
        }
Example #2
0
        private static LinqOp BuildOrderingOps(DirectVarUse keyVar, DirectVarUse valueVar,
                                               List <OrderingClause> /*!*/ clauses, LinqOp lastOp)
        {
            // PATTERNs:
            //	from x in e orderby k1 , k2, ..., kn [select v | group v by g]
            //
            // TRANSLATIONs:
            //	( e ) . OrderBy ( x => k1 ) . ThenBy ( x => k2 ) ... . ThenBy (x => kn) . Select ( x => v )
            //	( e ) . OrderBy ( x => k1 ) . ThenBy ( x => k2 ) ... . ThenBy (x => kn) . GroupBy ( x => g, x => v )

            Debug.Assert(clauses != null && clauses.Count > 0);

            for (int i = clauses.Count - 1; i >= 0; i--)
            {
                lastOp = new LinqOp.OrderBy(keyVar, valueVar, clauses[i].Expression, clauses[i].Ordering, lastOp, i != 0);
            }

            return(lastOp);
        }
Example #3
0
		private static LinqOp BuildTupleOrderingOps(List<OrderingClause> clauses)
		{
			// tuple of size n + 1
			// 
			// TRANSLATION:
			//  . OrderBy ( x => x[0] ) . ThenBy ( x => x[1] ) . ... . ThenBy ( x => x[n - 1] ) . Select ( x => x[n] )

			LinqOp last_op = new LinqOp.Select(null, null, new LinqTupleItemAccess(clauses.Count, clauses.Count + 1));

			for (int i = clauses.Count - 1; i >= 0; i--)
				last_op = new LinqOp.OrderBy(null, null, new LinqTupleItemAccess(i, clauses.Count + 1), clauses[i].Ordering, last_op, i != 0);

			return last_op;
		}
Example #4
0
		private static LinqOp BuildOrderingOps(DirectVarUse keyVar, DirectVarUse valueVar,
			List<OrderingClause>/*!*/ clauses, LinqOp lastOp)
		{
			// PATTERNs: 
			//	from x in e orderby k1 , k2, ..., kn [select v | group v by g]
			//
			// TRANSLATIONs:
			//	( e ) . OrderBy ( x => k1 ) . ThenBy ( x => k2 ) ... . ThenBy (x => kn) . Select ( x => v )
			//	( e ) . OrderBy ( x => k1 ) . ThenBy ( x => k2 ) ... . ThenBy (x => kn) . GroupBy ( x => g, x => v )

			Debug.Assert(clauses != null && clauses.Count > 0);

			for (int i = clauses.Count - 1; i >= 0; i--)
				lastOp = new LinqOp.OrderBy(keyVar, valueVar, clauses[i].Expression, clauses[i].Ordering, lastOp, i != 0);

			return lastOp;
		}