Relatude Help

Traverse

Traverse walks a relation out from the current result, breadth first, and returns the nodes it reaches. The current result is level 0, and you get every node whose shortest distance from it is between minLevel and maxLevel. Cycles are safe.

IQueryOfNodes<TProperty, TProperty> Traverse<TProperty>(
    Expression<Func<TNode, TProperty>> relationProperty,
    int maxLevel,
    int minLevel = 1,
    GraphDirection direction = GraphDirection.Default,   // or Reverse, or Both
    int? maxVisited = null);                             // a safety limit on wide graphs

When the property is a relation end, as in this manual's model, name the node type you traverse to. The result is an ordinary query of that type, so Where, OrderBy, Count, Page, Include and Facets all chain after it:

// Friends of Alice's friends, without her direct friends
var fof = db.Query<IAttendee>()
            .Where(aliceId)
            .Traverse<IAttendee>(a => a.Friends, maxLevel: 2, minLevel: 2)
            .Execute();

// The halls of a venue complex, at any depth
var halls = db.Query<IVenue>()
              .Where(complexId)
              .Traverse<IVenue>(v => v.Halls, maxLevel: 10)
              .Where(v => v.Capacity > 100)
              .OrderBy(v => v.Name)
              .Execute();