Using QueryOver to get all the entries in the base_example table for the BaseExample class, you will do the following: -
session.QueryOver<BaseExample>().List();
to get all the records of Example1 you do it
session.QueryOver<Example1>().List();
to get all the entries in Example2 : -
session.QueryOver<Example2>().List();
In other words, NHibernate is smart enough to add a where Domain=1 or Domain=2 clause in the query for you automatically.
It should also be noted if you want all the records from the base table to have a loop, then you can do this: -
var list = session.QueryOver<BaseExample>().List(); foreach(var item in list) { if (item is Example1) Output(Example1)
source share