public override void VisitOrdering(Remotion.Linq.Clauses.Ordering ordering, QueryModel queryModel, Remotion.Linq.Clauses.OrderByClause orderByClause, int index) { _isInstanceQuery = false; var selector = SparqlGeneratorWhereExpressionTreeVisitor.GetSparqlExpression(ordering.Expression, _queryBuilder); if (selector is SelectVariableNameExpression) { var selectorVar = selector as SelectVariableNameExpression; _queryBuilder.AddOrdering(new SparqlOrdering("?" + selectorVar.Name, ordering.OrderingDirection)); } else { throw new NotSupportedException( String.Format("LINQ-to-SPARQL does not currently support ordering by the expression '{0}'", ordering.Expression)); } base.VisitOrdering(ordering, queryModel, orderByClause, index); }