Hello!
I have a strange problem with subproperty fetching. I have those entites (simplified)![]()
[Entity]
[Table('TipVozila')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
[EntityAuthorize]
TTipVozila = class
private
[Column('Id', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FId: Integer;
[Column('Opis', [], 50)]
FOpis: Nullable<string>;
public
property Id: Integer read FId write FId;
property Opis: Nullable<string> read FOpis write FOpis;
end;
[Entity]
[Table('Vozilo')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
[EntityAuthorize]
TVozilo = class
private
[Column('Id', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FId: Integer;
[Association([TAssociationProp.Lazy], CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('TipVozila', [], 'Id')]
FTipVozila: Proxy<TTipVozila>;
...
If I start the application and execute this query
crit := FManager.Find<TPot>;
if Filter<>'' then begin
crit.Where(
Dic.Pot.Vozilo.RegistrskaSt.Like(L+Filter+'%')
or Dic.Pot.Vozilo.Opombe.Like(L+Filter+'%')
or Dic.Pot.Opis.Like(L+Filter+'%')
);
end;
crit.OrderBy('Vozilo');
crit.Refreshing; // Da ne dela samo s cache-om
crit.FetchEager('Vozilo');
crit.FetchEager('Vozilo.TipVozila');
adsView.SetSourceCriteria(crit);
adsView.Open;
Then I get the TVozilo entities that have TipVozila set as nil and if I try to edit one, I get access violation:

if itm.Vozilo.TipVozila.Id = Ord(tvNorba) then begin // <-- Access violation, TipVozila not assigned
frmEditPotNorba := TfrmEditPotNorba.Create(self, itm);
frmEditPotNorba.ShowModal;
But if I open the application and first execute this:
crit := FManager.Find<TVozilo>;
crit.OrderBy('RegistrskaSt');
crit.FetchEager('TipVozila');
Then the error does not appear on the process described above. I wonder what am I doing wrong.
Why are the TipVozila properties fetched in the first query and not in the second case?
Kind regards!
