XData service error in JSON converter

Hello,
I had the following classes and on a service call of the form "XClient.Service<ICoreService>.Saveitemdocument(aSalesInvoice)" I get the error
"Could not find JSON converter for type Proxy<AppEntities.TBranch>".

Appentities is the unit which contains all my classes and in SalesInvoice class I am using single table inheritance strategy .


What I am missing?

  [Entity]
  [Table('ItemDocument')]
  [Inheritance(TInheritanceStrategy.SingleTable)]
  [DiscriminatorColumn('DOC_TYPE',TDiscriminatorType.dtString)]
  [Sequence('IdentityOrSequence')]
  [Id('FID', TIdGenerator.IdentityOrSequence)]
  TItemDocument = class
  private
    [Column('ID', [TColumnProp.Required])]
    FID: Integer;
 
    [Column('Version', [])]
    [Version]
    FVersion: Nullable<Integer>;

    [Transient, XDataProperty]
    FDeletedList: TList<TItemDocumentLine>;

    [Association([TAssociationProp.Lazy], [])]
    [JoinColumn('BranchID', [], 'ID')]
    FBranchID: Proxy<TBranch>;
   
    [ManyValuedAssociation([], [TCascadeType.SaveUpdate, TCascadeType.Merge, TCascadeType.Remove], 'FItemDocumentID')]
    FItemDocument_ItemDocumentLineList: TList<TItemDocumentLine>;
    function GetBranchID: TBranch;
    procedure SetBranchID(const Value: TBranch);
  public
    constructor Create;
    destructor Destroy; override;
    property ID: Integer read FID write FID;
    property Version: Nullable<Integer> read FVersion write FVersion;
    property BranchID: TBranch read GetBranchID write SetBranchID;

    [Transient, XDataProperty]
    property DeletedList: TList<TItemDocumentLine> read FDeletedList write FDeletedList;

    property ItemDocument_ItemDocumentLineList: TList<TItemDocumentLine> read FItemDocument_ItemDocumentLineList;
  end;


  [Entity]
  [DiscriminatorValue('S')]
  TSalesInvoice = class(TItemDocument)
  private
   FInvCode: Nullable<Double>;
  public
   property InvCode: Nullable<Double> read FInvCode write FInvCode;
  end;

  [Entity]
  [DiscriminatorValue('P')]
  TPurchInvoice = class(TItemDocument)
  private
   FPurcCode: Nullable<Double>;
  public
   property PurcCode: Nullable<Double> read FPurcCode write FPurcCode;
  end;
 

Hi George,

Have you added Aurelius.Mapping.Attributes to the uses clause of the unit where you declare such entities? We tried to reproduce the issue here but was not able to do so. The error indeed happen but only if you do not add such unit, meaning the class is not recognized as an Aurelius entity.
Or maybe you are using a different model when creating TXDataClient? Is the error client side or server-side?

I had put the Mapping.Attributes on the unit where I call the service method.
On all other units of my project was already in uses clause but the error persists on the client side (no compile or other runtime errors or many models).
The error stopped  when I decide to write all my entitities in one unit instead of two separate units where was before like below:
Appentities (contains TBranch class)
InvEntities (uses AppEntities and contains SalesInvoice class)
I dont know if that was the solution, but it is working now in my case.
Many thanks Wagner.

You have to put Aurelius.Mapping.Attriubtes in the unit where the entities are declared, in that case, Appentities and InvEntities.