XData WebClient and PATCH

Hello Wagner,

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?

Best regards

Hi Thomas,

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?

Ok, I have made a feature request.

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.)

What do you mean by "doesn't arrive"? Can you provide more detailed information?

Yes, I can.

I have subscribed the event OnUpdated

TMappingExplorer.Get( sys.ModelName).Events.OnUpdated.Subscribe( OnUpdated);

Here the procedure:

procedure TdmDatabase.OnUpdated( Args: TUpdatedArgs);
  SE: TsngEntity;
  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(  .... );

Here is the base class

  TsngEntity = class
    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;
    property sngState: Integer    read FsngState      write FsngState;
    property sngKey1: TGUID       read FsngKey1       write FsngKey1;
    property sngFilter: String    read FsngFilter     write FsngFilter;

Here the Entity

  {$I '..\sngModellistPerson.inc'}
  [Id('FPersonID', TIdGenerator.None)]
  TPerson = class(TsngEntity)
    [Column('p_id', [TColumnProp.Required])]
    FPersonID: TGuid;
    [Column('p_nummer', [], 40)]
    FNummer: Nullable<string>;

    ... and many more
    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
    property sngKey1;

    property sngFilter;

The client sends the entity with set the fields sngKey1 and sngFilter.

Is this understandable now?

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.

Are you able to send a project reproducing the issue?

I'll try it. But it could take a few days. I have to see how I can do it.