Many to many with Aurelius

I have not located at the user manual for Aurelius examples relationship many to many.
Does anyone have this documentation or something?
Preferably it is bidirectional

You should create an intermediate class that represents the Many-to-many relationship (since a many-to-many is just two one-to-many relationships anyway), for example:


TStudentRoom = class
  FStudent: TStudent;
  FRoom: TRoom;


So that would for example mean:


TStudent=class
    [ManyValuedAssociation([], CascadeTypeAll, 'fStudent')] 
    property StudentRoom: TList<TStudentRoom> read fStudentRoom write fStudentRoom ;
end;

TClass=class
    [ManyValuedAssociation([], CascadeTypeAll, 'fClass')] 
    property StudentRoom: TList<TStudentRoom> read fStudentRoom write fStudentRoom ;
end;

TStudentRoom=class
    [Association([TAssociationProp.Lazy], [])]
    [JoinColumn('ID_STUDENT', [])]
    fStudent: Proxy<TStudent>;

    [Association([TAssociationProp.Lazy], [])]
    [JoinColumn('ID_CLASS', [])]
    fClass: Proxy<TClass>;
end;


One would ideally want some behaviour like:

TStudent=class
    property Rooms: TList<TRoom> read GetRooms write SetRooms;
end;

TClass=class
    property Students: TList<TSTudent> read GetStudents write SetStudents;
end;

The logic of translating an M:N into two 1:N relations would be taken care of behind-the-scenes.

How would you advise to get this desired behaviour?

There is no such automatic behaviour in Aurelius. We preferred to keep the engine simple and light since current approach is not limiting, the suggested approach just behaves as a "wizard", but do not add a new feature, exactly.


Hi!

Did I understand it correctly. It's possible with aurelius to build such behaviour.
Wagner you mention it this functionality is already there, are there any plans to build a 'wizard' for
the TMS Data modeler?


greets

René, there is no need of such wizard. If there is a table, for example, named "ClassStudent" that relates class and student, such table will be converted to a class TClassStudent and you can use it from Aurelius normally.


Hello!

That's clear. But it would be nice as mentioned above is you have for example a class TStucent and a class TRooms and the m-n-Table TStudentRooms.
Then it would be nice to have a property generated in TStudent to get a list of TRooms and in TRooms a property to get a list of TStudents.



greets

     -René

You just enable the ManyValuedAssociation (which is also available for 1:n relationships) that will give you a list of TStudentRoom in both Student and TRoom classes and you can get the other side from there.

Hello!

You're right. Sorry sometimes I don't see the wood for the trees!


regards

        -René