I have created 3 classes (songs, singers, albums)
The albums class has an one-to-many association to singers and a many-to-many association to songs.
In Talbum it exists:
[Id('Falbumid', TIdGenerator.None)] Talbums = class private [Column('albumid', [TColumnProp.Required])] Falbumid: Int64; [Association(, CascadeTypeAllButRemove)] [JoinColumn('singerid', )] Fsinger: Tsinger; ..... [ManyValuedAssociation([TAssociationProp.Required], [TCascadeType.SaveUpdate, TCascadeType.Merge],'falbum')] Fsongs:TList<Tsongs>;
In Tsongs it exists:
[Entity] [Table('mysongs')] [Id('Falbum', TIdGenerator.None)] [Id('Faa', TIdGenerator.None)] Tsongs = class private [Association([TAssociationProp.Required], CascadeTypeAll - [TCascadeType.Remove])] [JoinColumn('Falbumid', [TColumnProp.Required], 'Falbumid')] Falbum: Talbum; [Column('aa', [TColumnProp.Required])] Faa: Integer;
When I do a query like:
obj:=Context.GetManager; result:=obj.Find<Talbums> .CreateAlias('Tsongs','songs') .CreateAlias('Tsingers','singers') .Where( Linq.GreaterThan('date',a) and Linq.LessThan('date',b) and (linq['songs.time']<d)).List;
I can see in the logs that Aurelius does first a query with the 3 tables joined with the "where" expressions.
After that a big number of queries are issued for each song, with the the 3 tables joined for each index value of the table for Tsongs.
To my knowledge only the first query is needed, but in the first query, the table fields for Tsongs are not retrieved.
How to optimize that? Thank you in advance