Loading of derived classes on lists of base ones

Hello!

Suppose I have a TProductVariant class which inherits from TProduct. I have this in automapping so I don't know if the strategy matters, but basically I need to know this: when I make a list of TProducts via Criteria.List do the TProductVariant instances get loaded alongside the TProduct base classes? In other words, can I query for is TProductVariant when looping through the resulting list of TProduct?

And if the inheritance strategy matters, what strategy should I employ to make it work so that I can query for TProductVariant?
The reason I am asking is that the variants may have a different pricing and I need to show the correct price (there is a mechanism for this already) on the client.

Thanks!

Hi @Raimondi_Andrea,

I have this in automapping so I don't know if the strategy matters

Inheritance strategy is never automapped, so each and every class hierarchy that you have, you need to explicitly specify the inheritance strategy you want Aurelius to use.

when I make a list of TProducts via Criteria.List do the TProductVariant instances get loaded alongside the TProduct base classes

Yes.

In other words, can I query for is TProductVariant when looping through the resulting list of TProduct?

If you are asking if you can do something like this:

for Product in Criteria.List<TProduct> do
  if Product is TProductVariant then  
  begin
    Variant := TProductVariant(Product);
  end;

Then yes, you can do it.

And if the inheritance strategy matters,

No, it works for both joined tables and single table strategy.