Show/Hide Toolbars

TMS Aurelius Documentation

TAureliusDataset supports usage of Locate method to locate records in the dataset. Use it just as with any regular TDataset descendant:

 

Found := AureliusDataset1.Locate('Name''mi', [loCaseInsensitive, loPartialKey]);

 

You can perform locate on entity fields. Just note that since entity fields hold a reference to the object itself, you just need to pass a reference in the locate method. Since objects cannot be converted to variants, you must typecast the reference to an Integer or IntPtr (Delphi XE2 and up).

 

{$IFDEF DELPHIXE2}

Invoices.Locate('Customer', IntPtr(Customer), []);

{$ELSE}

Invoices.Locate('Customer', Integer(Customer), []);

{$ENDIF}

 

The customer object must be the same. Even if Customer object has the same Id as the object in the dataset, if the object references are not the same, Locate will fail. Alternatively, you can also search on sub-property fields:

 

Found := Invoices.Locate('Customer.Name', Customer.Name, []);

 

In this case, the record will be located if the customer name matches the specified value, regardless if object references are the same or not.

You can also search on calculated and lookup fields.