EntityToQuery
Convert an entity or array of entities to a Query object.
The query holds one row per entity and one column per id, column, version and timestamp property, inherited ones included.
The result query will not contain any relation data. Relationship properties (one-to-one, one-to-many, many-to-one, many-to-many) are not included as columns. See Entities as Queries for details and alternatives.
Method Signature
EntityToQuery(entity=[Any], name=[Any])Arguments
entity
Any
true
An instance of an ORM entity or an array of entities. All entities in an array must be of the same type.
name
Any
false
The name of the entity. Inferred from the (first) entity when omitted. Useful to pick the entity with inheritance.
Examples
Convert a Single Entity
Pass one loaded entity to get a single-row query result.
result = entityToQuery( entityLoadByPK( "Vehicle", "1HGCM82633A123456" ), "Vehicle" );Convert an Entity Array
Pass an array of entities to get one row per entity.
You can also omit the entity name and let the function infer it from the entity type:
Note that for performance reasons we recommend passing the entity name explicitly.
See Entities as Queries for the full guide.
Related
Last updated
Was this helpful?