#1 2018-01-13 11:59:07

mORMotStudent
Member
Registered: 2018-01-04
Posts: 4

TSQLRecord.TObjectList<T>: is it possible?

Hi,

I am beginning to look at it now and I really liked this very good framework, so I am considering to use it in my project.

But I have some objects that I want to persist in a database whose classes have generic TObjectList<T> properties set in then.

So, would it be possible to use these generic properties with mormot or am I forced to use a simple TObjectList?


Just to show what I mean, look at this little example:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

TExampleClass = class(TSQLRecord);

TMySQLRecordClass = class(TSQLRecord)
  private
    FMYObjList: TObjectList<TExampleClass>;
    procedure SetMYObjList(const Value: TObjectList<TExampleClass>);

  published
    property MYObjList : TObjectList<TExampleClass> read FMYObjList write SetMYObjList;   
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////


I know mormot have compability with many prior delphi versions, But I think it would be great if we could use a generic like this, it would make it easier to implement on my project;

Last edited by mORMotStudent (2018-01-13 12:00:34)

Offline

#2 2018-01-13 15:40:52

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

Re: TSQLRecord.TObjectList<T>: is it possible?

The idea here may be to define and use a TObjArray, which works with any version of Delphi and FPC.

Online

#3 2018-01-15 11:34:21

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: TSQLRecord.TObjectList<T>: is it possible?

mORMotStudent wrote:

Hi,

I am beginning to look at it now and I really liked this very good framework, so I am considering to use it in my project.

But I have some objects that I want to persist in a database whose classes have generic TObjectList<T> properties set in then.

So, would it be possible to use these generic properties with mormot or am I forced to use a simple TObjectList?


Just to show what I mean, look at this little example:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

TExampleClass = class(TSQLRecord);

TMySQLRecordClass = class(TSQLRecord)
  private
    FMYObjList: TObjectList<TExampleClass>;
    procedure SetMYObjList(const Value: TObjectList<TExampleClass>);

  published
    property MYObjList : TObjectList<TExampleClass> read FMYObjList write SetMYObjList;   
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////


I know mormot have compability with many prior delphi versions, But I think it would be great if we could use a generic like this, it would make it easier to implement on my project;


mORMot and DDD changed my mind. Now, I have two data models, one for database aggregation with simple types (Arrays and records) and another model for frontend representation and logic (ObjectList, Methods). It's better to separate models than have only one model for logic and aggregation. Correct me Arnaud if I am wrong.

Last edited by turrican (2018-01-15 11:41:31)

Offline

#4 2018-01-15 15:17:31

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

Re: TSQLRecord.TObjectList<T>: is it possible?

+1

Online

Board footer

Powered by FluxBB