Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Queries

Polymorphism

Scroll Prev Top Next More

Since Aurelius supports inheritance using different inheritance strategies, queries are also polymorphic. It means that if you query over a specified class, you might receive objects of that class, or even descendants of that class.

 

For example, suppose you have a class hierarchy this way:

 

TAnimal = class

TBird = class(TAnimal);

TMammal = class(TAnimal);

TDog = class(TMammal);

TCat = class(TMammal);

 

when you perform a query like this:

 

Results := Manager.Find<TMammal>
  .Add(Linq['Name'].Like('T%'))
  .List;

 

You are asking for all mammals which Name begins with "T". This means all mammals, dogs and cats. So in the resulted object list, you might receive instances of TMammal, TDog or TCat classes. Aurelius does it automatically for you, regardless on the inheritance strategy, i.e. if all classes are being saved in the same table or each class is being saved in a different table. Aurelius will be sure to filter out records representing animals and birds, and retrieve only the mammals (including dogs and cats).

 

You can safely rely on polymorphism with Aurelius in every query, and also of course, when saving and updating objects.