All about Fetch Models - fieldenms/tg GitHub Wiki
Introduction
A fetch model represents a graph that describes the shape of an entity to be fetched.
Fetch Categories
An essential component of a fetch model is its category, which defines a set of properties that are implicitly included in a fetch model.
Fecth categories are defined by ua.com.fielden.platform.entity.query.fluent.fetch.FetchCategory
.
Description of each category follows, with the categories ordered by richness, ascendingly (the last category includes the most properties).
NONE
- nothing is included.ID_ONLY
- sole propertyid
is included.ID_AND_VERSION
- a slightly broader fetch model thanID_ONLY
.id
is included if it belongs to the entity type;version
is included if the entity type is persistent;refCount
andactive
are included if entity type is activatable;- the group of "last updated by" properties is included if the entity type is persistent and has those properties.
DEFAULT
- equivalent toALL
but with narrower sub-fetch models - only simple keys and key members will have a sub-fetch model other thanID_ONLY
.KEY_AND_DESC
key
is included;desc
is included if it belongs to the entity type.- all of
ID_AND_VERSION
are included if the entity type is persistent;
ALL
- includes all retrievable properties, except the following:- collectional properties are excluded;
- non-retrievable properties are excluded;
- calculated properties are excluded (unless they have a component type).
ALL_INCL_CALC
(all, including calculated) - equivalent toALL
but also includes calculated properties.
API
Core abstractions for fetch models in the platform code are:
ua.com.fielden.platform.entity.fetch.IFetchProvider
- application developer facing API, used for Web UI and entity companions.ua.com.fielden.platform.entity.query.fluent.fetch
- application developer facing API, used for EQL queries.ua.com.fielden.platform.entity.query.IRetrievalModel
- internal representation, used by the EQL engine.
Fetching sub-properties of a component type
TG version 2.0.0 Fetching of standalone sub-properties of a component type is unsupported. The whole component-typed property must be fetched.
For example, let Note
be an entity with property text: RichText
.
fetch1 = fetchNone(Note.class).with("text.coreText");
fetch2 = fetchNone(Note.class).with("text");
query = select(Note.class).yieldAll().modelAsEntity(Note.class);
Then, query
with fetch1
will produce notes with property text
proxied, while with fetch2
- all components of RichText will be retrieved and text
will be assigned a corresponding value.