Format of a row returned from an ECSQL SELECT query

A row returned from an ECSQL SELECT query is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.

Property names

If the ECSQL select clause item

  • has a column alias, the alias, with the first character lowered, becomes the property name.

  • has no alias and is no ECSQL system property, the ECSQL select clause item, with the first character lowered, becomes the property name.

  • is an ECSQL system property (see also enum ECSqlSystemProperty):

    System property JavaScript Type
    ECInstanceId id
    ECClassId className
    SourceECInstanceId sourceId
    SourceECClassId sourceClassName
    TargetECInstanceId targetId
    TargetECClassId targetClassName
    Navigation property member JavaScript Type
    Id id
    RelClassId relClassName
    Point property member JavaScript Type
    X x
    Y y
    Z z

Property value types

The resulting types of the returned property values are these:

ECSQL type Extended Type JavaScript Typ
Boolean - boolean
Blob - Uint8Array
Blob BeGuid GuidString
ClassId system properties - fully qualified class name
Double - number
DateTime - ISO 8601 date time string
Id system properties - Id64String
Integer - number
Int64 - number
Int64 Id hexadecimal string
Point2d - XAndY
Point3d - XYAndZ
String - string
Navigation n/a NavigationValue
Struct n/a JavaScript object with properties of the types in this table
Array n/a array of the types in this table

Examples

ECSQL Row
SELECT ECInstanceId,ECClassId,Parent,LastMod,FederationGuid,UserLabel FROM bis.Element {id:"0x132", className:"generic.PhysicalObject", parent:{id:"0x444", relClassName:"bis.ElementOwnsChildElements"},lastMod:"2018-02-27T14:12:55.000Z",federationGuid:"274e25dc-8407-11e7-bb31-be2e44b06b34",userLabel:"My element"}
SELECT s.ECInstanceId schemaId, c.ECInstanceId classId FROM meta.ECSchemaDef s JOIN meta.ECClassDef c ON s.ECInstanceId=c.Schema.Id {schemaId:"0x132", classId:"0x332"}
SELECT count(*) FROM bis.Element {"count(*)": 31241}
SELECT count(*) cnt FROM bis.Element {cnt: 31241}

Last Updated: 21 May, 2020