Filtering Sub-Properties for SQL-Expressions

there is a stored tree, that is filtered using SQL-Expressions:

[Entity]
TEntity = class
private
  FId: TGUID;
  FNumber: Integer;
  FParent: TEntity;
...

ObjectManager.Find<TEntity>
  .Where(Linq.Sql<Integer>('{' + Dic.Entity.Parent.AssociationName + '}.{' + Dic.Entity.Parent.Number.PropName + '} = ?', 1))
  .UniqueResult;

=> Raises:
Server-side error while retrieving data:
EPgNativeException: [FireDAC][Phys][PG][libpq] FEHLER: cross-database references are not implemented: a.parent_id.a.number

This example is simplified from our current implementation, that does not allow to use CreateAlias or stuff like that...
Any suggestions?

Doing this with less curly brackets and fetcheager works fine:

ObjectManager.Find<TEntity>
  .FetchEager(Dic.Entity.Parent.AssociationName)
  .Where(Linq.Sql<Integer>('{' + Dic.Entity.Parent.AssociationName + '.' + Dic.Entity.Parent.Number.PropName + '} = ?', 1))
  .UniqueResult;
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.