I solved by inserting a fake ID field in the view ...
not beautiful but it works ...
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This is the view
CREATE OR REPLACE VIEW public.riepilogopertipologia(
id,
Descr,
Count)
AS
SELECT row_number() OVER(
ORDER BY ta.Descr) AS id,
ta.Descr,
count(*) AS Count
FROM apparati ap
LEFT JOIN tipiapparati ta ON ta.id = ap.idtipoapparato
WHERE ap.seattivo = true
GROUP BY ta.Descr;
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This is the class
TRiepilogoPerTipologiaVWTableDictionary = class;
[Entity]
[Table('RiepilogoPerTipologia')]
[Description('')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TRiepilogoPerTipologiaVW = class
private
[Column('Id', [TColumnProp.Required])]
[Description('')]
FId: Int64;
[Column('Count', [])]
[Description('')]
FCount: Int64;
[Column('Descr', [], 80)]
[Description('')]
FDescr: string;
public
constructor Create;
destructor Destroy; override;
property Id: Int64 read FId;
property Descr: string read FDescr;
property Count: Int64 read FCount;
end;
TRiepilogoPerTipologiaVWTableDictionary = class
private
//FId: TDictionaryAttribute;
FCount: TDictionaryAttribute;
FDescr: TDictionaryAttribute;
public
constructor Create;
//property Id: TDictionaryAttribute read FId;
property Descr: TDictionaryAttribute read FDescr;
property Count: TDictionaryAttribute read FCount;
end;
implementation
{ TRiepilogoPerTipologiaVW }
constructor TRiepilogoPerTipologiaVW.Create;
begin
inherited;
end;
destructor TRiepilogoPerTipologiaVW.Destroy;
begin
inherited;
end;
{ TRiepilogoPerTipologiaVWTableDictionary }
constructor TRiepilogoPerTipologiaVWTableDictionary.Create;
begin
inherited;
//FId := TDictionaryAttribute.Create('Id');
FCount := TDictionaryAttribute.Create('Count');
FDescr := TDictionaryAttribute.Create('Descr');
end;
end.