You are not logged in.
In the following code:
type
Tmyorm=class(Torm)
private
Fwasadded: boolean;
published
property wasadded:boolean read Fwasadded write Fwasadded;
end;
procedure TForm3.Button1Click(Sender: TObject);
var lista:ilist<Tmyorm>; o:tmyorm; fin:tarray<tmyorm>; n:integer; b:boolean;
begin
lista:=collections.Newplainlist<Tmyorm>([loCreateUniqueIndex],nil,ptOrm);
for n:=0 to 4 do
begin
o:=tmyorm.Create;
o.IDValue:=1;
lista.add(o,@b);
o.wasadded:=b;
if not b then o.free;
end;
fin:=lista.AsArray;
memo1.lines.add(dynarraysavejson(fin,typeinfo(tarray<tmyorm>)));
end;I am getting:
[{"RowID":1,"wasadded":true},{"RowID":1,"wasadded":true},{"RowID":1,"wasadded":true},{"RowID":1,"wasadded":true},{"RowID":1,"wasadded":true}]What am I doing wrong?
Offline
Since I created the list with loCreateUniqueIndex and ptOrm, why Torm objects are added with the same IDvalue?
Offline
Should I check before adding? if so, what does the second parameter in ilist<>.add?
Offline