This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
dataClass.get( )

dataClass.get( ) 


 

dataClass.get ( primaryKey {; settings} ) -> Result 
Parameter Type   Description
primaryKey  Longint, Text in Primary key value of the entity to retrieve
settings  Object in Build option: context
Result  Entity in Entity matching the designated primary key

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 

Created: 4D v17

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)