I have an [XDataProperty] for a field in the data record that should not be saved in the database. I urgently need this field in the OnInserting, OnInserted, etc. events.
If I now change the data set with a PATCH command, everything works fine.
If I take PUT, this field is empty, i.e. not set.
Now I work with the XData WebClient. And the WebClient doesn't have a PATCH.
For testing purposes, I added the PATCH function to the XData.Web.Client.pas file. This works on my first test.
Well, why didn't you include this feature in the client?
If it's really that simple, can you extend this function?
Yes, for the Web Client we can add the Patch function. It's not there because such function can't be added to the regular, non-web TXDataClient. Would you mind filing a feature request for this?
Do you have any idea why the [XDataProperty] doesn't arrive in the "OnUpdated" event during the PUT command?
(but with the PATCH command (for example from Postman) it arrives.)
procedure TdmDatabase.OnUpdated( Args: TUpdatedArgs);
var
SE: TsngEntity;
begin
if Args.Entity is TsngEntity then begin
SE := TsngEntity( Args.Entity);
// !!!
// at this point the Entity Fields are empty if I send a PUT and not empty if I send a PATCH
// !!!
ServerApp.Call( .... );
end;
end;
end;
Here is the base class
TsngEntity = class
private
FsngState: Integer; // this fields are in the DB
// and more DB columns
FsngKey1: TGuid // this fields are not in the DB;
FsngFilter: String; // this fields are not in the DB;
public
property sngState: Integer read FsngState write FsngState;
property sngKey1: TGUID read FsngKey1 write FsngKey1;
property sngFilter: String read FsngFilter write FsngFilter;
end;
Here the Entity
[Entity]
[Table('t_p_person')]
{$I '..\sngModellistPerson.inc'}
[Id('FPersonID', TIdGenerator.None)]
TPerson = class(TsngEntity)
private
[Column('p_id', [TColumnProp.Required])]
FPersonID: TGuid;
[Column('p_nummer', [], 40)]
FNummer: Nullable<string>;
... and many more
public
constructor Create;
destructor Destroy; override;
property PersonID: TGuid read FPersonID write FPersonID;
property Nummer: Nullable<string> read FNummer write FNummer;
... and many more
[Column('sngstate', [TColumnProp.Required])]
property sngState;
... here also more
and here are the important fields
[XDataProperty]
property sngKey1;
[XDataProperty]
property sngFilter;
end;
The client sends the entity with set the fields sngKey1 and sngFilter.
But which fields, exactly.
Note that behavior is somehow expected, because PUT creates a new instance of the class and only updates the properties sent from the client, while PATCH loads the properties from the database and then updates the properties sent from the client.
The "sngKey1" and "Filter".
These fields are NOT stored in the database.
I use these fields to send information from the client to the server, which should then be used there for further processing.
The “real” database fields are processed without errors.