public static IGremlinQuery <T> ByMember <T>(this IGremlinQuery <T> query, Expression <Func <T, object> > projection, GremlinSortOrder sortOrder = GremlinSortOrder.Increasing) { var body = projection.Body; if (body is UnaryExpression && body.NodeType == ExpressionType.Convert) { body = ((UnaryExpression)body).Operand; } var memberExpression = body as MemberExpression; if (memberExpression != null) { return(query .AddStep <T>("by", memberExpression.Member.Name, new SpecialGremlinString(sortOrder.ToString().Substring(0, 4).ToLower()))); } throw new NotSupportedException(); }
public static IGremlinQuery <T> ByTraversal <T>(this IGremlinQuery <T> query, Func <IGremlinQuery <T>, IGremlinQuery> traversal, GremlinSortOrder sortOrder = GremlinSortOrder.Increasing) { return(query .AddStep <T>("by", traversal(query.ToAnonymous()), new SpecialGremlinString(sortOrder.ToString().Substring(0, 4).ToLower()))); }