private Tuple<> ParseOrderByPart(string orderByPart)
{
const string ascMark = " asc";
var descMark = " desc";
if (orderby.EndsWith(ascMark, true, CultureInfo.InvariantCulture))
{
orderby = orderby.Substring(0, orderby.Length - ascMark.Length);
query.SortOrder = SortOrder.Ascending;
}
else if (orderby.EndsWith(descMark, true, CultureInfo.InvariantCulture))
{
orderby = orderby.Substring(0, orderby.Length - descMark.Length);
query.SortOrder = SortOrder.Descending;
}
else
query.SortOrder = SortOrder.Ascending;
Type orderedType;
if (query.GroupByExpression != null)
{
// When groupby is added to query, ordering will occur AFTER select, not before.
orderedType = query.SelectExpression.ReturnType;
}
else
{
orderedType = query.OfType.Type;
}
query.OrderByExpression = parser.Parse(orderedType, orderby);
}
#endif