GORMDocs
QUERYING

Start with LINQ. Add graph intent when the path matters.

GORM keeps node-root queries familiar, then adds explicit graph operators for traversal, relationship loading and time-aware inspection.

QUERY ROOTS

Begin from a typed node set

var services = context.Set<ServiceNode>();

From there you can use familiar filtering, ordering, projection, paging and aggregation patterns.

FILTERING

Keep ordinary predicates ordinary

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.

TRAVERSAL

Traversal makes the relationship part of the query

var dependencies = await context.Set<ServiceNode>()
    .Where(x => x.Id == apiId)
    .Outgoing<DependsOnEdge, ServiceNode>()
    .ToListAsync();
ServiceNodeWHERE Id == apiIdOutgoing<DependsOnEdge>ServiceNode

This is not just syntactic sugar for a hidden repository join. The edge type and direction are part of the query semantics.

CHAINED TRAVERSAL

Follow multi-hop relationships deliberately

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.

INCOMING

Reverse the question without reversing the model

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.

INCLUDE

Use Include for object materialization

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.

PAGING

Apply ordering before bounded reads

var page = await context.Set<ServiceNode>()
    .Where(x => x.State == ServiceState.Active)
    .OrderBy(x => x.Name)
    .Skip(100)
    .Take(50)
    .ToListAsync();
PredictabilityUse deterministic ordering when paging. Stable ordering matters even more when results are later used as roots for graph traversal.
TEMPORAL

Move the graph query through time

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.

SQL INSPECTION

Translation should be visible

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.

GORM
context.Set<PersonNode>()
    .Where(x => x.Id == personId)
    .Outgoing<WorksOnEdge, ProjectNode>()
SQL SHAPE
SELECT target.*
FROM PersonNode source,
     WorksOnEdge edge,
     ProjectNode target
WHERE MATCH(source-(edge)->target)
  AND source.Id = @personId;
PLAYGROUNDEdit this query

Change the LINQ and inspect the translated query shape, graph path and notes.

RUNTIME EVIDENCE

Query the real public package

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.

QUERY DESIGN

Keep graph questions focused

FILTER EARLY

Narrow roots

Reduce candidate source nodes before expanding through relationships where semantics allow it.

TYPE EDGES

Be specific

Choose the edge type that represents the domain relationship rather than generic catch-all connections.

INSPECT

Read the SQL

Translation visibility helps catch accidental fan-out, unnecessary materialization and ambiguous intent.