TSelectorConstraint (selector)

De Wiki1000
(Différences entre les versions)
(Exemples d'utilisation de contrainte)
(Exemples d'utilisation de contrainte)
Ligne 52 : Ligne 52 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TObject;
+
var selA:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
Ligne 64 : Ligne 64 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selB:TSelector; obj:TObject;
+
var selB:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
 
   selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
Ligne 76 : Ligne 76 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TObject;
+
var selA:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
Ligne 89 : Ligne 89 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selB:TSelector; obj:TObject;
+
var selB:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
 
   selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
Ligne 102 : Ligne 102 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TObject;
+
var selA:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
Ligne 117 : Ligne 117 :
 
<source lang="delphi">
 
<source lang="delphi">
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
 
function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TObject;
+
var selA:TSelector; obj:TSelectorConstraint;
 
begin
 
begin
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
 
   selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);

Version du 5 juillet 2016 à 13:28

versionlatest-32x32.png

TSelectorConstraint:TObject;

Cet objet matérialise une contrainte posée sur un sélecteur.

Attributs

Attribut Usage
Parent Objet parent de la contrainte
ClassName Nom de la classe sur laquelle porte la sélection
Left Nom de l'attribut gauche
Right Nom de l'attribut droit
Where Clause Where de la contrainte
ArgCount Nombre d'arguments de la clause where
Args[] Argument de la clause where

Méthodes d'instance

Méthode Usage
Delete Supprime la contrainte

Exemples d'utilisation de contrainte

Selector constraint 1.jpg

Contrainte venant d'une référence

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TSelectorConstraint;
begin
  selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
  obj  := selA.AddConstraint(nil, 'ClassB','oid','refB','unCodeB=%1',[iCodeB]);
  Result := selA.Count;
end;

Contrainte venant d'une référence inversée

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selB:TSelector; obj:TSelectorConstraint;
begin
  selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
  obj  := selB.AddConstraint(nil, 'ClassA','refB','oid','unCodeA=%1',[iCodeA]);
  Result := selB.Count;
end;

Contrainte en cascade

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TSelectorConstraint;
begin
  selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
  obj  := selA.AddConstraint(nil, 'ClassB','oid','refB','unCodeB=%1',[iCodeB]);
  obj  := selA.AddConstraint(obj, 'ClassA2','refB','oid','AliasOf(''ClassA'',''unCodeA'')=unCodeA',[]);
  Result := selA.Count;
end;

Contrainte entre classes

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selB:TSelector; obj:TSelectorConstraint;
begin
  selB := ClassB.CreateSelector('unCodeB=%1','unCodeB',True,[iCodeB]);
  obj  := selB.AddConstraint(nil, 'ClassA','refB','oid','',[]);
  obj  := selB.AddConstraint(nil, 'ClassA2','refB','oid','(AliasOf(''ClassA'',''unCodeA'')=unCodeA2) and (unCodeA2=%1)',[iCodeA]);
  Result := selB.Count;
end;

Mise à jour

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TSelectorConstraint;
begin
  selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
  obj  := selA.AddConstraint(nil, 'ClassB','oid','refB','unCodeB=%1',[iCodeB]);
  withP long transaction do
   begin
     Result := selA.Update(['unEntierA'],[0]);
   end;
end;

Mise à jour en utilisant un attribut de la contrainte

function doSelector(const iCodeA:string; const iCodeB:string):Integer;
var selA:TSelector; obj:TSelectorConstraint;
begin
  selA := ClassA.CreateSelector('unCodeA=%1','unCodeA',True,[iCodeA]);
  obj  := selA.AddConstraint(nil, 'ClassB','oid','refB','unCodeB=%1',[iCodeB]);
  obj  := selA.AddConstraint(obj, 'ClassA2','refB','oid','AliasOf(''ClassA'',''unCodeA'')=unCodeA2',[]);
  withP long transaction do
   begin
     Result :=  selA.Update(['unEntierA'],['ClassA2.unEntierA2']);
   end;
end;

Voir aussi :

Selecteur (tech)Développement DSM

Outils personnels