MySQL · Types · Entities and values
ArxEntityReference
Definition
- Namespace
ARX.SDK.Services- Package
ARX.SDK
public class ArxEntityReferenceA lookup: a reference to a record of another table, by that table's name and the record's id. Written to a lookup column as the id; the table name tells ARX which table the id belongs to, so a schema can check it.
Constructor
ArxEntityReference()An empty reference; set its table and id.
ArxEntityReference(string entityName, long id, string? name = null)A reference by an integer id (short, int and long all fit).
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idlongThe referenced record's integer id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, Guid id, string? name = null)A reference by a uuid id.
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idGuidThe referenced record's uuid id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, string id, string? name = null)A reference by a text id (a country code, a SKU).
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idstringThe referenced record's text id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, decimal id, string? name = null)A reference by a decimal id.
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. iddecimalThe referenced record's decimal id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, DateOnly id, string? name = null)A reference by a date id.
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idDateOnlyThe referenced record's date id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, DateTime id, string? name = null)A reference by a timestamp id.
Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idDateTimeThe referenced record's timestamp id. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it. ArxEntityReference(string entityName, ArxRecordId id, string? name = null)A reference by the id Create returned (
await service.CreateAsync(account)), of any type.Parameter Type Description entityNamestringThe referenced table: the table the id belongs to. idArxRecordIdThe id CreateAsync returned for the referenced record, of any id type. namestring?= nullIts display name, if you have it; optional, ARX doesn't write it.
Properties
ArxRecordId? RecordId { get; }The referenced record's id, of any supported type; null when none was given. This is what Create writes to the lookup column.
None(a record of a table with no id column) can't be referenced.long Id { get; set; }Obsolete. Id is only an integer id: 0 for a Guid or text id. Use RecordId (RecordId.Value, AsInt64(), AsGuid(), AsString()).The referenced record's id when it's an integer; 0 otherwise (a Guid or text id reads as 0). Setting it sets
RecordId. UseRecordId, which holds an id of any type.Guid Guid { get; set; }Obsolete. Guid is only a Guid id: Guid.Empty for an integer or text id. Use RecordId (RecordId.Value, AsGuid()).The referenced record's id when it's a Guid;
Guid.Emptyotherwise. Setting it setsRecordId. UseRecordId, which holds an id of any type.string EntityName { get; set; }The referenced table: checked against the schema when there is one (it must be declared, with an id of the reference's type).
string? Name { get; set; }The referenced record's display name, if known. Not written by Create.
Usage
A line from a verified sample; the full, runnable code is on its page.
contact["account_id"] = new ArxEntityReference("account", account.RecordId); // the table, then the idCreate a record that points at another one, scenario 1
Used in:
- Create a record that points at another oneCreate
- Where to declare: on the entity, or a schema for one call, never bothCreate
- A sign-up form creates an accountCreate
- Every supported .NET type, and what MySQL storesCreate
- Instants, local times, dates and times of dayCreate
- Picklist values checked against the application's catalogCreate
- Natural ids, uuid ids and a table with a compound keyCreate
- Register ARX in a DI container and inject itCreate
- Several calls in one ARX transaction: commit or roll backCreate
- Write to two databases, each with its own serviceCreate
- Preload the schema at service setup: keys only, data types, StrictCreate
- Save an account's contacts in one callCreateMultiple
- Import a 20,000-item product feed in one callCreateMultiple
- Import 5,000 contacts in batches, in one transactionCreateMultiple
- An order and its lines: all steps or noneCreateMultiple
- Create an order and update the stock, all or nothingUpdate
- A referenced record: ARX3002, then delete in orderDelete
- Replace an order's lines: delete, create, update, all or nothingDelete
- Accounts and contacts in one queryRetrieveMultiple
- Read a viewRetrieveMultiple
- Rows from a function: refused on MySQL, and what to read insteadRetrieveMultiple
- Lookups and display namesRetrieveMultiple
- Read in a batch scopeRetrieveMultiple
- Filter expressions in depth: nesting, recursion, links, And and OrRetrieveMultiple
- Link entities in depth: chains, branches, criteria per level, recursionRetrieveMultiple
- Read other row sources: a view in a schema, a summary view, a table with no idRetrieveMultiple
- Functions in depth on MySQL: tables, procedures and scalar values instead of row sourcesRetrieveMultiple
- Views in depth: computed criteria, links both ways, declared ids and lookups, column boundariesRetrieveMultiple
- Retrieve on a preloaded schema: lookups found, column types, Strict, saved JSONRetrieveMultiple
- Read OUT and INOUT valuesExecute
- Call a function: a value, rows, an effectExecute
- A report with several result setsExecute
- A nightly job that commits in batchesExecute
Notes
The id can be of any supported id type: short, int, long, decimal, string, Guid, DateOnly or DateTime, or the ArxRecordId that Create returned. Every constructor takes the table name first, then the id, then an optional display name.