I have TEchoServerModule on a Datamodule in my xData restserver with MSSQL db. Using Route I'm only replicating 1 entity (DemoTable). This Entity looks like:
For testing I've used your EchoTestDemo project to point to my server and using the correct model/entity.
With both my rest Server and client running, I POST a new record into DemoTable using my rest Server's Swagger ui. Record is posted successfully, and values are confirmed in my MSSQL db:
ID = 27, ParentID = NULL, Name = "First Record"
Now, when refreshing Client1 and Client2 (in the EchoTestDemo project), I see a newly replicated record with field Name = "First record" as expected, BUT field ID = 1 (Not ID = 27 as I'd expect).
Any hints or tips as to what I'm doing wrong or misunderstanding here?
You should remove the TColumnProp.NoInsert flag from the FID field, otherwise it will never be present in the INSERT SQL statement executed by Echo when the record is loaded:
Ok, I have now removed the TColumnProp.NoInsert and now the fields ID and Name are replicated just fine, thank you.
But I seem to have an issue with the last field, ParentID. As seen from the model this field is a FK to the
same table. Too me it looks like the field ParentID "gets" an incorrect value client-side.
To demonstrate my issue I deleted all Echo tables and db's on server and client side, and emptied the DemoTable in my server db (MSSQL). So from a completely clean start on both server and client side I do this:
Start my xData rest server.
Start my client demo project (your EchoTestDemo).
Using swagger I POST an initial new record to the DemoTable/Enity on the sever, with values: (PS. the autogenerated value of ID becomes 30)
Using swagger I POST a second record to the DemoTable/Enity on the server with values:
Data are confirmed in my server DB correctly:
But the data replicated to my client(s) look like this:
Thus, the dataset will show the pointer to the object, not the actual ID field value. Since they are effectively different object instances, their values will be different.
To see the parent ID value, create a dataset field named ParentID.ID and you will be able to see it (and you can use the same approach to see other properties, like ParentID.Name).
Ah, of course. I keep missing basic functionality, guess it's a result of doing too many things at once
Thank you for your great support, and your patience.