Relatude Help

14 Relating nodes

Name a relation by one of its relation properties, as a lambda, and pass the two nodes or their ids:

db.AddRelation<IVenue>(venue, v => v.Events, ev);                   // node objects
db.AddRelation<IVenue>(venueId, v => v.Events, eventId);            // ids
db.AddRelation<IVenue>(venueId, v => v.Events, new[] { eventId1, eventId2 });

db.RemoveRelation<IVenue>(venue, v => v.Events, ev);

bool related = db.RelationExists<IVenue>(venueId, v => v.Events, eventId);

It does not matter which end you name: db.AddRelation<IEvent>(ev, e => e.Venue, venue) does the same as the first line. A symmetric relation is stated once: after db.AddRelation<IAttendee>(alice, a => a.Friends, bob), each is in the other's Friends.

Every relation method exists on NodeStore, where it commits at once, and on Transaction, where it returns the transaction so calls chain.

  • Which verb — The six verbs differ only in what they do when the relation is already there, or when the cardinality leaves no room: