Relatude Help

29 Cultures, visibility and scoped stores

A query reads through a context: a culture, a user, and what counts as visible. Set it per query:

db.Query<IEvent>()
  .WhereCulture("nb-NO")
  .WhereCultureFallback(true)
  .Execute();

db.Query<IEvent>(QueryContext.Default.Culture("nb-NO")).Execute();

A QueryContext starts from QueryContext.Default, Anonymous or MasterAdmin, and each of its methods returns a new context. Or scope a whole NodeStore once and reuse it. The scoped store shares the data and indexes, and only reads differently:

var nb = db.Context.Culture("nb-NO").CultureFallbacks().Create();

nb.Query<IEvent>().Execute();
nb.Get<IVenue>(venueId);

A web app builds one per request, as the visitor:

var visitor = db.Context.Culture(cultureCode).User(userId ?? Guid.Empty).Create();
Setting Effect
Culture(code) Read in this culture
CultureFallbacks() When a node has nothing in the culture, read another version (below)
User(userId) Read as this user node; read access follows its groups. Guid.Empty is an anonymous visitor
Admin() Read as the master admin, with no access filtering
Unpublished() Also read drafts and other unpublished revisions, and nodes outside their release and expiry dates
EditView() Also require edit-view access, as for an editor
Hidden() Include nodes of hidden types
Now(utc) Check release and expiry dates against this time
With(queryContext) Use a context built elsewhere

db.Context.Admin() bypasses access control. Use it only in trusted server code, and never hand it to a request handler.

Get and TryGet by id apply the context's culture but not its read access. Queries and relation properties do apply it. To check what a visitor may read, query:

bool canRead = visitor.Query().Where(id).Count() > 0;
  • Revisions in several cultures — A node starts with one version. EnableRevisions, or its first CreateRevision, turns it into revisions: versions with an id, a RevisionType, a culture and values of their own.