Projections on Association-Fields

Is there any possibility, to fetch associated id-field using Projections?
I'm providing dataset-values for a Lookup-control like this:

For example:

TEntity = class;
[Entity]
TLanguage = class
private
  FLang: string;
  FValue: string;
  FEntity: Proxy<TEntity>;
end;

TEntity = class
private
  FLang: TList<TLanguage>;
end;

begin
  // only fetch visible columns
  ObjectManager.Find<TLanguage>
    .Select(TProjections.ProjectionList
      .Add(Linq['entity_id'])
      .Add(Linq['value'])
    );
end;

After selection of a record, I'll load the full entity, to append it by using associations.
But this way, I do not have to fetch both full entities, which is really faster for big entities...

You can use Linq['Entity.id'].

I could, but this would execute a not necessary left join...

It would be fine, if this would just use the current column...

You can ask for the underlying database field:

.Add(TProjections.Sql<Integer>('ENTITY_ID'))

ok, thanks, I didn't recognize, that projections supports Sql-Method.

1 Like

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