New Property FullAssociationName for TAureliusEntityDictionary

If you would like to access an association-field using projections, you would have to use TProjections.Sql.

TProjections.Sql<Integer>('{' + EntDic.Entity.Child.AssociationName + '}');

We are using this a lot.
So it would be fine, if there would be another Property in IAureliusEntityDictionary, returning your required { }.

EntDic.Entity.Child.TaggedAssociationName;
would return:
'{Child}'

My next point is, that accessing sub association-fields is a bit annoying...

TProjections.Sql<Integer>('{' + EntDic.Entity.Child.AssociationName + '.' + EntDic.Entity.Child.AnotherChild.AssociationName + '}');

It would be realy nice, if IAureliusEntityDictionary would also provide a property, that would return the full AssociationName.

TProjections.Sql<Integer>('{' EntDic.Entity.Child.AnotherChild.FullAssociationName + '}');


would return:
'Child.AnotherChild'

or even better:

TProjections.Sql<Integer>(EntDic.Entity.Child.AnotherChild.TaggedFullAssociationName);

would return:
'{Child.AnotherChild}'

So you would not have to do that: (from TAureliusEntityDictionary.GetAssociationName) ...

repeat
    P := Pos('.', Result);
    if P > 0 then
      Delete(Result, 1, P);
  until P = 0;

I believe you are using the "old" dictionary? If you use the new one, it already works like that.

https://doc.tmssoftware.com/biz/aurelius/guide/dictionary.html#associations

We are generating our Dictionary using TDictionaryGenerator.Create.

So I believe it should be the "new" one.

I think you misunderstood my request.

As you wrote, it works like that, you linked to Associations.
This describes, how these works for TLinqProjection.

This works fine as is.

But in an earlier task you told me, that I could access referenced Id behind an association by doing stuff like that:

Manager.Find<TEntity>.Select(TProjections.Sql<Integer>('child_entity_id')).List;

What I did is this:

Manager.Find<TEntity>.Select(TProjections.Sql<Integer>('{' + Dic.Entity.ChildEntity.AssociationName + '}')).List;

And this works fine, because I could go on use the dictionary and don't have to take care of changing column-names in several locations (or at least create a const for each column-name...)

or maybe another Example:

FetchEager:
Manager.Find<TEntiy>.FetchEager(Dic.Entity.Child.AssociationName).List;
works fine, but
Manager.Find<TEntiy>.FetchEager(Dic.Entity.Child.AnotherChild.AssociationName).List;
does not work, because you have to do it in that way:
Manager.Find<TEntiy>.FetchEager(Dic.Entity.Child.AssociationName + '.' + Dic.Entity.Child.AnotherChild.AssociationName).List;

it would be nice, if we could do this like that:
Manager.Find<TEntiy>.FetchEager(Dic.Entity.Child.AnotherChild.FullAssociationName).List;

You got these Informations already in TAureliusEntityDictionary.
But we could not access these...

That is what I don't get. The new dictionary doesn't provide any property named AssociationName.

here is an example of a generated Interface:

  IChangeLogDictionary = interface(IAureliusEntityDictionary)
    function Id: TLinqProjection;
    function TableName: TLinqProjection;
    function DatasetId: TLinqProjection;
    function ChangeType: TLinqProjection;
    function ChangedOn: TLinqProjection;
    function ChangedBy: TLinqProjection;
    function FieldLog: IFieldChangeLogDictionary;
  end;

  TChangeLogDictionary = class(TAureliusEntityDictionary, IChangeLogDictionary)
  public
    function Id: TLinqProjection;
    function TableName: TLinqProjection;
    function DatasetId: TLinqProjection;
    function ChangeType: TLinqProjection;
    function ChangedOn: TLinqProjection;
    function ChangedBy: TLinqProjection;
    function FieldLog: IFieldChangeLogDictionary;
  end;

{ TChangeLogDictionary }

function TChangeLogDictionary.Id: TLinqProjection;
begin
  Result := Prop('Id');
end;

function TChangeLogDictionary.TableName: TLinqProjection;
begin
  Result := Prop('TableName');
end;

function TChangeLogDictionary.DatasetId: TLinqProjection;
begin
  Result := Prop('DatasetId');
end;

function TChangeLogDictionary.ChangeType: TLinqProjection;
begin
  Result := Prop('ChangeType');
end;

function TChangeLogDictionary.ChangedOn: TLinqProjection;
begin
  Result := Prop('ChangedOn');
end;

function TChangeLogDictionary.ChangedBy: TLinqProjection;
begin
  Result := Prop('ChangedBy');
end;

function TChangeLogDictionary.FieldLog: IFieldChangeLogDictionary;
begin
  Result := TFieldChangeLogDictionary.Create(PropName('FieldLog'));
end;

So if this is old, how can I generate a new dictionary?
Right now, we are generating our dictionary, as you describe in your docs:
https://doc.tmssoftware.com/biz/aurelius/guide/dictionary.html#generate-from-application

I understand what you mean now. I believe you can accomplish what you want just using the Alias property:

Manager.Find<TEntiy>.FetchEager(Dic.Entity.Child.AnotherChild.Alias).List;

Therefor you have to implement Alias in IAureliusEntityDictionary

That's what I was trying to tell you.

You have Alias in TAureliusEntityDictionary already, but we could not access it, because IAureliusEntityDictionary does not implement this.

Ok. This will be implemented in the next version.

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