4D v19

dataClass.get( )

Home

 
4D v19
dataClass.get( )

dataClass.get( )  


 

The dataClass.get( ) method queries the dataclass to retrieve the entity matching the primaryKey parameter.

In primaryKey, pass the primary key value of the entity to retrieve. The value type must match the primary key type set in the datastore (longint or text). You can also make sure that the primary key value is always returned as text by using the entity.getKey( ) method with the dk key as string parameter.

If no entity is found with primaryKey, a Null entity is returned.

Lazy loading is applied, which means that related data is loaded from disk only when it is required.

In the optional settings parameter, you can pass an object containing additional options. The following property is supported:

PropertyTypeDescription
contextTextLabel for the automatic optimization context applied to the entity. This context will be used by the subsequent code that loads the entity so that it can benefit from the optimization. This feature is designed for client/server processing; for more information, please refer to the Client/server optimization section.

 C_OBJECT($entity)
 $entity:=ds.Employee.get(167) // return the entity whose primary key value is 167
 $entity:=ds.Invoice.get("DGGX20030") // return the entity whose primary key value is "DGGX20030"

This example illustrates the use of the context property:

 C_OBJECT($e1;$e2;$e3;$e4;$settings;$settings2)
 
 $settings:=New object("context";"detail")
 $settings2:=New object("context";"summary")
 
 $e1:=ds.Employee.get(1;$settings)
 completeAllData($e1// In completeAllData method, an optimization is triggered and associated to context "detail"
 
 $e2:=ds.Employee.get(2;$settings)
 completeAllData($e2// In completeAllData method, the optimization associated to context "detail" is applied
 
 $e3:=ds.Employee.get(3;$settings2)
 completeSummary($e3//In completeSummary method, an optimization is triggered and associated to context "summary"
 
 $e4:=ds.Employee.get(4;$settings2)
 completeSummary($e4//In completeSummary method, the optimization associated to context "summary" is applied



See also 

entity.getKey( )
Find in field
QUERY

 
PROPERTIES 

Product: 4D
Theme: ORDA - DataClass

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)