#1 2013-01-24 17:55:21

arquivo59
Member
Registered: 2013-01-14
Posts: 24

TObjectList

Hi,

Wich TObjectList can I use with Interface Based Services, from the unit WebAdapt or System.Generics.Collections???

Offline

#2 2013-01-24 20:13:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: TObjectList

We expect and tested the Contnrs.TObjectList class.
mORMot does not use nor support WebAdapt, but I think it is the same as Contnrs.TObjectList, so it should work.

But System.Generics.Collections.TObjectList won't work, since it is a diverse type than Contnrs.TObjectList, and is generic-based.
I suspect writing a patch to handle it in addition to TObjectList won't easily be possible - generics are indeed creating one instantiation class type at compile time for each type argument.
So there is no parent class able to identify all TObjectList<T> at once, ad we do for Contnrs.TObjectList...
Perhaps we may be able to define some class helpers to handle those, but I can't find any easy solution... Perhaps each TObjectList<T> type should be registered as such.
Do you have any idea?

We can always convert any TObjectList<T> into a plain TObjecTList.
Then if you register each class type T, you will be able to serialize it.

Offline

#3 2013-01-24 20:50:19

arquivo59
Member
Registered: 2013-01-14
Posts: 24

Re: TObjectList

Ok, thanks.

I'm having some troubles with this approach. Error : "Class TBankVO" not found".

  
  TBankVO = class(TSQLRecord)  
  private
    FCODIGO: String;
    FNOME: String;

  published
    [TFormatter(100, taCenter, True, True)] // this is a custom attribute
    property Codigo: String read FCODIGO write FCODIGO;
    property Nome: String read FNOME write FNOME;

I have a procedure in a interface:

  IBancoController = interface(IInvokable)
              ['{078EF22D-E687-44AE-8E9F-47C841095108}']
              procedure Get(var Result: TObjectList);
          end; 

When I'm calling from the client a found this error every time.

Offline

#4 2013-01-24 21:29:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: TObjectList

You have to explicitly register the type if it is not part of a model.

On both sides.

Note that for a result, out is preferred
to var.

Offline

#5 2013-01-24 23:23:16

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: TObjectList

AB, what you think about writing this methos as a function Get: TObjectList?

Other question: when is better to use collections and when is better to use TObjectList with mORMot?

Offline

#6 2013-01-24 23:51:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: TObjectList

1. With registered types we may had class instances as results.

2. A matter of taste. TObjectList are easier but less strongly typed.
But with TObjectlist you can mix classes within the list.

Offline

#7 2013-01-25 09:38:27

TommyYommi
Member
Registered: 2013-01-18
Posts: 27

Re: TObjectList

Hi,

AB, How many objects do you recomend to send using one TObjectList??

Offline

#8 2013-01-25 09:42:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: TObjectList

It should stay in memory, it should not contain a lot of BLOBs, it should not use too much bandwidth...
But serialization/unserialization should be fast.
If you find any performance issue, don't hesitate to report here.

So no special recommendation.

Offline

Board footer

Powered by FluxBB