fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
381 stars 182 forks source link

Entity nested with other entity collection #109

Open danilobicas-unoeste opened 6 years ago

danilobicas-unoeste commented 6 years ago

Hi. I receiving error when result comes from webapi to delphi. Follow below the entities in my webapi....

class moviment mov_codigo:int; collection itens;

class itens ite_codigo: int; produto: produtcs;

class products pro_codigo:int; pro_value:decimal;

When I receive my json from webapi Delphi show me a message: Class T not found. when I click OK it show next message(more specific): UnMarshalling error for field "moviment.itens" : class T not found.

In my class in delphi I do as follow:

class moviment mov_codigo:int; itens: TObjectList; class itens ite_codigo: int; produto: TObject;;

class products pro_codigo:int; pro_value:decimal; I thinks this is the error but I don't know how I fix this.

Please help!!!!

thomaserlang commented 6 years ago

Your code is rather hard to read.
Try something like this:

itens: TObjectList<TItens>;

You need to tell delphi what type of object the list will contain.

danilobicas-unoeste commented 6 years ago

Yes but my delphi is 2007 and don't accept TObjectList.... Unfortunately

Tks

Danilo

2018-02-22 19:37 GMT-03:00 Thomas Erlang notifications@github.com:

Your code is rather hard to read. Try something like this:

itens: TObjectList;

You need to tell delphi what type of object the list will contain.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fabriciocolombo/delphi-rest-client-api/issues/109#issuecomment-367846911, or mute the thread https://github.com/notifications/unsubscribe-auth/AL6w0FPuMMwB9BVSv9_2zaNfLvaWivpxks5tXexAgaJpZM4SP7o2 .

danilobicas-unoeste commented 6 years ago

follow below my delphi code `MovimentoProdutoViewModel = class private Fmov_codigo: integer; Fmop_quantidade: currency; Fpro_codigo: integer; Flab_produtos: TObject; protected public constructor Create; destructor Destroy; published property pro_codigo:integer read Fpro_codigo write Fpro_codigo; property mov_codigo:integer read Fmov_codigo write Fmov_codigo; property mop_quantidade:currency read Fmop_quantidade write Fmop_quantidade; property ProdutosViewModel:TObject read Flab_produtos write Flab_produtos; end;

MovimentoViewModel = class

private Fmov_codigo: integer; Fmov_data: string; Ftpm_codigo: integer; Fmov_descricao: string; Fmov_nota: string; Flab_movimentoprodutoviewmodel: TObjectList; FTipoMovimentoViewModel: TObject;

protected

public constructor Create; destructor Destroy; published property mov_codigo: integer read Fmov_codigo write Fmov_codigo; property tpm_codigo: integer read Ftpm_codigo write Ftpm_codigo; property mov_data:string read Fmov_data write Fmov_data; property mov_nota:string read Fmov_nota write Fmov_nota; property mov_descricao:string read Fmov_descricao write Fmov_descricao; property MovimentoProdutoViewModel: TObjectList read Flab_movimentoprodutoviewmodel write Flab_movimentoprodutoviewmodel; property TipoMovimentoViewModel: TObject read FTipoMovimentoViewModel write FTipoMovimentoViewModel; end;

constructor MovimentoViewModel.Create; begin Flab_movimentoprodutoviewmodel:= TObjectList.Create; FTipoMovimentoViewModel:=TObjectList.Create; end;

destructor MovimentoViewModel.Destroy; begin Flab_movimentoprodutoviewmodel.Destroy; FTipoMovimentoViewModel.Destroy; end; ` Previously I said that my delphi is 2007 and I can´t put TObjectList

can you help me?