#1 2015-06-18 09:07:44

cypriotcalm
Member
Registered: 2015-02-18
Posts: 122

DDD ORMSelectAll

There is a method ORMSelectAll in the class TDDDRepositoryRestQuery.

But with this method I can only select records meeting some WHERE-condition. How can I select all records, e.g. like select * from <table>, from a table?

Now I select all records in the following way:

function TPhoMessartCommand.Select: TCQRSResult;
begin
  Result := ORMSelectAll('?=?', [1,1]);
end;

Could we have something like? Would this make sense?

function TPhoMessartCommand.Select: TCQRSResult;
begin
  Result := ORMSelectAll('*', []);
end;

// or

function TPhoMessartCommand.Select: TCQRSResult;
begin
  Result := ORMSelectAll();
end;

Offline

#2 2015-06-18 10:57:14

noobies
Member
Registered: 2011-09-13
Posts: 139

Re: DDD ORMSelectAll

try this?

function TPhoMessartCommand.Select: TCQRSResult;
begin
  Result := ORMSelectAll('', []);
end

Offline

#3 2015-06-18 11:32:11

cypriotcalm
Member
Registered: 2015-02-18
Posts: 122

Re: DDD ORMSelectAll

noobies wrote:

try this?

function TPhoMessartCommand.Select: TCQRSResult;
begin
  Result := ORMSelectAll('', []);
end

I have already tried it out before, but it didn't work

Offline

#4 2015-06-18 15:02:02

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

Re: DDD ORMSelectAll

There was indeed a weird restriction in TSQLRecord.FillPrepare().

I've ensured that ORMSelectAll('',[]) would return all aggregates, as we should expect.
And included the regression tests.
See http://synopse.info/fossil/info/d358af2109

Note that returning ALL aggregates may not be DDD-aware at all...
The point of the Aggregate is to have all data for a given bounded context.
Retrieving all aggregates may not make sense...

Thanks for the feedback.

Offline

#5 2015-06-18 18:46:10

cypriotcalm
Member
Registered: 2015-02-18
Posts: 122

Re: DDD ORMSelectAll

ab wrote:

Note that returning ALL aggregates may not be DDD-aware at all...
The point of the Aggregate is to have all data for a given bounded context.
Retrieving all aggregates may not make sense...

It's a good point! I have already refactored some classes ;-) But sometimes I have to retrieve all records from a table for an overview, e.g. in my case I want to let a user gets an overview about all measurement types (TPhoMessart is a measurement type) in the system, so I have to call something like TPhoMessart.SelectAll(out AMessarts: TMessarts);

A further question:
Is it a good idea to use as an aggregate class the same class which maps my messart-table in the database, i.e. TPhoMessart for both as an aggregate and as TSQLRecord class?

Offline

Board footer

Powered by FluxBB