How to handle slightly different Entity requirements in 2 apps?

We have 2 applications (lets call them client and server for convenience) that talk to each other. They each have a different database, but have the same table, Shipments. The only difference is that the server table has an additional field.

we have an entity TShipment which is based on the client database (so does not have the additional field defined.

The server has a service method RegisterShipment(AShipment: TShipment). To enable this to write to the database we need to populate the additional field. We can create a TServerShipment entity (descended from TShipment?) populate that by writing an Assign method and saving that, but the question is: Is there a better, simpler way of doing this in Aurelius?

Thanks

There are multiple ways to solve this, even if you had a single application. You could use multimodel design, dynamic properties, inheritance, as you mentioned, etc.

But your situation seems to be simpler, as I understand there are 2 different applications and you simply want to share the code that declares the entities, right?
Then why don't you simply use conditional directives, add the additional field under such directive and only enable that directive when compiling the server app?

{$IFDEF SERVERAPP}
  FSomeField: string;
{$ENDIF}
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.