/// <summary>Compile query to sort the table by the index.</summary> public static SortQuery <tRow> sort <tRow, tKey>(iTypeSerializer ser, Expression <Func <tRow, tKey> > exp, bool descending) where tRow : new() { var me = exp.Body as MemberExpression; if (null == me) { throw new NotSupportedException("Currently, orderBy[Descending] only supports ordering by a single column."); } IndexForColumn[] indices = ser.indicesFromColumn(me.Member); bool indexDirectionPositive, multi; string ind = ser.sortIndex(me.Member, out indexDirectionPositive, out multi); bool shouldInvert = descending ^ (!indexDirectionPositive); return(new SortQuery <tRow>(r => r.filterSort(ind, shouldInvert), multi)); }