Osy#betaRun it on Osyrin: osyrin.com

Reference / Entity

[Title] on an entity

[Title(<Member>, <Member>…)] entity <Name> { … } · [Title($"…{Member}…")] entity <Name> { … }

`[Title]` on an entity says what each of its records is called — the line a notification, a search result or a link shows for it. `Records.Title(x)` answers it for any row.

stable1 example compiled by CIentitymodelrecords

Summary#

[Title(Number, Subject)] on an entity names what each of its records is called: here its number and subject, joined with " · ". A template says it in your own words — [Title($"#{Number} · {Subject}")]. Anything that shows a record it did not declare — a notification's line, a feedback comment, a link — asks Records.Title(x), and gets this.

Signature#

[Title(Member1, Member2, …)]          // the members' values, joined with " · ", empty ones left out
[Title($"#{Number} · {Subject}")]     // an interpolated template over the record's own members
entity <Name> { … }

Description#

What is a record called without one?#

Its first [Required] text member — a Name, a Title, a Subject is usually exactly right, which is why most entities need no [Title] at all. With none, its type's noun ("Ticket").

Does a derived type inherit it?#

Yes. A type with no [Title] of its own is called by its nearest ancestor's; one of its own replaces it.

Is it translated?#

The values are the record's own; the literal words in a template are not translated yet. Keep a template to punctuation and numbers (#{Number} · {Subject}) where the app speaks more than one language.

Where is it on the page?#

[Title] on a page component is the same idea for a route — its name, for chrome that names a route. On an entity it names each record.

Examples#

Counter OrderNumber = new() { Start = 1000 };

/// "#1042 · Two city bikes"
[Title($"#{Number} · {Summary}")]
entity Order {
  [Counter(OrderNumber)] int Number;
  [Required, MaxLength(200)] string Summary;
  security { allow read, create when IsAuthenticated; }
}

/// "Ada Lovelace · London"
[Title(Name, City)]
entity Customer {
  [Required, MaxLength(100)] string Name;
  [MaxLength(100)] string City = "";
  security { allow read, create when IsAuthenticated; }
}

/// No [Title]: called by its first required text — "Spring catalogue".
entity Catalogue {
  [Required, MaxLength(100)] string Label;
  security { allow read, create when IsAuthenticated; }
}

public string Called(Order o, Customer c, Catalogue k) {
  return Records.Title(o) + " | " + Records.Title(c) + " | " + Records.Title(k);
}

See also#

Related

Records — what any record is called, where it opens, who may read it

`Records.*` answers facts about a row of ANY type from what the app declared — what it is called (`[Title]`), where it…

Entity

`Entity` is a reference to a row of ANY type the app keeps — what a notification, a comment or a question "about some…

entity

Declares a persisted type — a table of rows the app stores, queries and secures. Every entity gets an Id from the…