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

Home

 
4D v19.8
entitySelection.minus( )

entitySelection.minus( ) 


 

entitySelection.minus ( entity | entitySelection ) -> Result 
Parameter Type   Description
entity | entitySelection  Entity, EntitySelection in Entity or entity selection to substract
Result  EntitySelection in New entity selection or a new reference on the existing entity selection

The entitySelection.minus( ) method excludes from the entity selection to which it is applied the entity or the entities of entitySelection and returns the resulting entity selection.

  • If you pass entity as parameter, the method creates a new entity selection without entity (if entity belongs to the entity selection). If entity was not included in the original entity selection, a new reference to the entity selection is returned.
  • If you pass entitySelection as parameter, the method returns an entity selection containing the entities belonging to the original entity selection without the entities belonging to entitySelection

Note: You can compare ordered and/or unordered entity selections. The resulting selection is always unordered. For more information, please refer to the Ordered vs Unordered entity selections paragraph in the 4D Developer Guide.

If the original entity selection or both the original entity selection and the entitySelection parameter are empty, an empty entity selection is returned.
If entitySelection is empty or if entity is Null, a new reference to the original entity selection is returned.

If the original entity selection and the parameter are not related to the same dataClass, an error is raised.

 C_OBJECT($employees;$employee;$result)
 
 $employees:=ds.Employee.query("lastName = :1";"H@") // The $employees entity selection contains the entity with primary key 710 and other entities
  // for ex. "Colin Hetrick", "Grady Harness", "Sherlock Holmes" (primary key 710)
 
 $employee:=ds.Employee.get(710) // Returns "Sherlock Holmes"
 
 $result:=$employees.minus($employee//$result contains "Colin Hetrick", "Grady Harness"

We want to have a selection of female employees named "Jones" who live in New York :

 C_OBJECT($sel1;$sel2;$sel3)
 $sel1:=ds.Employee.query("name =:1";"Jones")
 $sel2:=ds.Employee.query("city=:1";"New York")
 $sel3:=$sel1.and($sel2).minus(ds.Employee.query("gender='male'"))



See also 

DIFFERENCE
entitySelection.add( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - EntitySelection

 
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)