Narrow roots
Reduce candidate source nodes before expanding through relationships where semantics allow it.
GORM keeps node-root queries familiar, then adds explicit graph operators for traversal, relationship loading and time-aware inspection.
var services = context.Set<ServiceNode>();From there you can use familiar filtering, ordering, projection, paging and aggregation patterns.
var active = await context.Set<ServiceNode>()
.Where(x => x.State == ServiceState.Active)
.Where(x => x.Region == "eu-west")
.OrderBy(x => x.Name)
.Take(50)
.ToListAsync();Graph-specific syntax is unnecessary when the query only targets properties on one node type.
var dependencies = await context.Set<ServiceNode>()
.Where(x => x.Id == apiId)
.Outgoing<DependsOnEdge, ServiceNode>()
.ToListAsync();This is not just syntactic sugar for a hidden repository join. The edge type and direction are part of the query semantics.
var downstream = await context.Set<ServiceNode>()
.Where(x => x.Id == gatewayId)
.Outgoing<RoutesToEdge, ServiceNode>()
.Outgoing<DependsOnEdge, ServiceNode>()
.ToListAsync();Each hop should remain typed and inspectable so the query tells the reader which topology is being followed.
var dependents = await context.Set<ServiceNode>()
.Where(x => x.Id == databaseId)
.Incoming<DependsOnEdge, ServiceNode>()
.ToListAsync();Incoming traversal asks which source nodes point to the current target through the chosen edge type.
var person = await context.Set<PersonNode>()
.Include(x => x.Projects)
.SingleAsync(x => x.Id == personId);Include is for loading a connected object graph. Traversal is for asking a graph path question. Prefer the operator that communicates the intent of the query.
var page = await context.Set<ServiceNode>()
.Where(x => x.State == ServiceState.Active)
.OrderBy(x => x.Name)
.Skip(100)
.Take(50)
.ToListAsync();var historical = await context.Set<ServiceNode>()
.AsOf(incidentStartedAt)
.Where(x => x.Id == serviceId)
.Outgoing<DependsOnEdge, ServiceNode>()
.ToListAsync();A temporal graph query should interpret node and edge state at the same historical point so topology and scalar state remain coherent.
The browser Playground demonstrates expected SQL shapes using a JavaScript preview translator, not the compiled GORM library. For authoritative SQL, run the NuGet cookbook's real Explain() example and consult the SQL Server compatibility matrix.
context.Set<PersonNode>()
.Where(x => x.Id == personId)
.Outgoing<WorksOnEdge, ProjectNode>()SELECT target.*
FROM PersonNode source,
WorksOnEdge edge,
ProjectNode target
WHERE MATCH(source-(edge)->target)
AND source.Id = @personId;Change the LINQ and inspect the translated query shape, graph path and notes.
The verified NuGet cookbook includes executable assertions for the actual GORM APIs shown here. The SQL Server compatibility matrix clearly separates in-memory demonstrations from provider-backed tests.
Reduce candidate source nodes before expanding through relationships where semantics allow it.
Choose the edge type that represents the domain relationship rather than generic catch-all connections.
Translation visibility helps catch accidental fan-out, unnecessary materialization and ambiguous intent.