a simple example
abstract class Car
{
public virtual long SerialNumber { get; set; }
}
class Mercedes : Car { }
class Fiat : Car { }
class Toyota : Car { }
now i want to query for which types inheriting from car are on stock. How to do this? Or is my design flawed.
example
session.Save(new Mercedes() { SerialNumber = 1 });
session.Save(new Mercedes() { SerialNumber = 2 });
session.Save(new Toyota() { SerialNumber = 1 });
// later
var models = session2.Query<Car>().SelectDistinct(car => car.GetType().Name);
showModelComboBox.Items = models;
From what I can see, the following works:
…and you can apply
Distinctlater… but it’s actually fetching the whole entities.Not good.
It looks like
Distinctcan’t be applied to aGetTypeexpression.Now, you can do the following:
It will return the raw discriminators, which is not ideal, but it works.